Improved the autocomplete typing experience

This commit is contained in:
WBHarry 2026-02-04 21:50:44 +01:00
parent 735ed4c214
commit 044d184832
5 changed files with 26 additions and 7 deletions

View file

@ -54,7 +54,11 @@ export default class AttributionDialog extends HandlebarsApplicationMixin(Applic
const after = label.slice(matchIndex + search.length, label.length); const after = label.slice(matchIndex + search.length, label.length);
const element = document.createElement('li'); const element = document.createElement('li');
element.innerHTML = `${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`; element.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
if (item.hint) { if (item.hint) {
element.dataset.tooltip = game.i18n.localize(item.hint); element.dataset.tooltip = game.i18n.localize(item.hint);
} }

View file

@ -70,7 +70,11 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
element.appendChild(img); element.appendChild(img);
const label = document.createElement('span'); const label = document.createElement('span');
label.innerHTML = `${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`; label.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
element.appendChild(label); element.appendChild(label);
return element; return element;
@ -119,7 +123,11 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
element.appendChild(img); element.appendChild(img);
const label = document.createElement('span'); const label = document.createElement('span');
label.innerHTML = `${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`; label.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
element.appendChild(label); element.appendChild(label);
return element; return element;

View file

@ -68,14 +68,18 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
}, },
render: function (item, search) { render: function (item, search) {
const label = game.i18n.localize(item.label); const label = game.i18n.localize(item.label);
const matchIndex = label.toLowerCase().indexOf(search); const matchIndex = label.toLowerCase().indexOf(search.toLowerCase());
const beforeText = label.slice(0, matchIndex); const beforeText = label.slice(0, matchIndex);
const matchText = label.slice(matchIndex, matchIndex + search.length); const matchText = label.slice(matchIndex, matchIndex + search.length);
const after = label.slice(matchIndex + search.length, label.length); const after = label.slice(matchIndex + search.length, label.length);
const element = document.createElement('li'); const element = document.createElement('li');
element.innerHTML = `${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`; element.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
if (item.hint) { if (item.hint) {
element.dataset.tooltip = game.i18n.localize(item.hint); element.dataset.tooltip = game.i18n.localize(item.hint);
} }

View file

@ -103,7 +103,11 @@ export default class SettingActiveEffectConfig extends HandlebarsApplicationMixi
const after = label.slice(matchIndex + search.length, label.length); const after = label.slice(matchIndex + search.length, label.length);
const element = document.createElement('li'); const element = document.createElement('li');
element.innerHTML = `${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`; element.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
if (item.hint) { if (item.hint) {
element.dataset.tooltip = game.i18n.localize(item.hint); element.dataset.tooltip = game.i18n.localize(item.hint);
} }

View file

@ -32,7 +32,6 @@
li[role='option'] { li[role='option'] {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px;
font-size: var(--font-size-14); font-size: var(--font-size-14);
padding: 0 10px; padding: 0 10px;
cursor: pointer; cursor: pointer;