Preferences: Fix and improve search

This commit is contained in:
Abe Jellinek 2024-01-17 13:45:29 -08:00 committed by Dan Stillman
parent 6e651271e8
commit 1d662b9fef
3 changed files with 34 additions and 23 deletions

View file

@ -218,6 +218,7 @@ var Zotero_Preferences = {
this.navigation.append(listItem);
let container = document.createElement('div');
container.classList.add('pane-container');
container.hidden = true;
this.helpContainer.before(container);
@ -276,8 +277,13 @@ var Zotero_Preferences = {
let heading = document.createElement('h1');
heading.textContent = pane.rawLabel;
pane.container.append(heading);
pane.container.append(contentFragment);
if (pane.container.querySelector('.main-section')) {
pane.container.querySelector('.main-section').prepend(heading);
}
else {
pane.container.prepend(heading);
}
await document.l10n.ready;
await document.l10n.translateFragment(pane.container);
@ -585,12 +591,13 @@ ${str}
let termForDisplay = Zotero.Utilities.trimInternal(term).toLowerCase();
term = this._normalizeSearch(term);
for (let container of this.content.children) {
let root = container.firstElementChild;
if (!root) continue;
for (let child of root.children) {
let matches = await this._findNodesMatching(child, term);
for (let paneContainer of this.content.querySelectorAll(':scope > .pane-container')) {
let roots = paneContainer.children;
while (roots.length === 1 && roots[0].childElementCount) {
roots = roots[0].children;
}
for (let root of roots) {
let matches = await this._findNodesMatching(root, term);
if (matches.length) {
let touchedTabPanels = new Set();
for (let node of matches) {
@ -642,10 +649,14 @@ ${str}
}
}
else {
child.classList.add('hidden-by-search');
child.ariaHidden = true;
root.classList.add('hidden-by-search');
root.ariaHidden = true;
}
}
if (Array.from(roots).every(root => root.classList.contains('hidden-by-search'))) {
paneContainer.classList.add('hidden-by-search');
paneContainer.ariaHidden = true;
}
}
}),

View file

@ -203,7 +203,6 @@
<label value="&zotero.preferences.trashAutoEmptyDaysPost;"/>
</hbox>
</groupbox>
</vbox>
<groupbox>
<label><html:h2>&zotero.preferences.groups;</html:h2></label>
@ -218,3 +217,4 @@
</vbox>
</groupbox>
</vbox>
</vbox>

View file

@ -222,7 +222,7 @@ groupbox:not(:first-of-type) label > h2 {
}
.hidden-by-search {
display: none;
display: none !important;
}
prefwindow .chromeclass-toolbar