Persist local match alternatives collapsed state
Store the expanded/collapsed state of local match alternative sections in localStorage so the UI preference is remembered across sessions.
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
const isHidden = element.classList.toggle('mr-hidden');
|
||||
if (trigger) {
|
||||
trigger.setAttribute('aria-expanded', String(!isHidden));
|
||||
if (trigger.dataset?.mlPreference === 'local-match-alternatives') {
|
||||
window.ModelResolverDialog?.setLocalMatchAlternativesCollapsed?.(isHidden);
|
||||
}
|
||||
const label = trigger.querySelector?.('.mr-local-alternatives-label');
|
||||
const state = trigger.querySelector?.('.mr-local-alternatives-state');
|
||||
if (label || state) {
|
||||
|
||||
@@ -69,11 +69,17 @@ export class ResolverManagerDialog extends ComfyDialog {
|
||||
this.sidebarOpenModeStorageKey = "model_resolver_sidebar_open_mode";
|
||||
this.missingBrowserSplitStorageKey = "model_resolver_missing_browser_detail_w";
|
||||
this.showResolvedModelsStorageKey = "model_resolver_show_resolved_models";
|
||||
this.localMatchAlternativesCollapsedStorageKey = "model_resolver_local_match_alternatives_collapsed";
|
||||
try {
|
||||
this.showResolvedModels = localStorage.getItem(this.showResolvedModelsStorageKey) === '1';
|
||||
} catch (e) {
|
||||
this.showResolvedModels = false;
|
||||
}
|
||||
try {
|
||||
this.localMatchAlternativesCollapsed = localStorage.getItem(this.localMatchAlternativesCollapsedStorageKey) === '1';
|
||||
} catch (e) {
|
||||
this.localMatchAlternativesCollapsed = false;
|
||||
}
|
||||
this.dockButton = null;
|
||||
this.undockButton = null;
|
||||
this._floatingRectBeforeDock = null;
|
||||
|
||||
@@ -1763,6 +1763,30 @@ export const searchPanelMethods = {
|
||||
};
|
||||
},
|
||||
|
||||
areLocalMatchAlternativesCollapsed() {
|
||||
if (typeof this.localMatchAlternativesCollapsed === 'boolean') {
|
||||
return this.localMatchAlternativesCollapsed;
|
||||
}
|
||||
|
||||
try {
|
||||
this.localMatchAlternativesCollapsed = localStorage.getItem(this.localMatchAlternativesCollapsedStorageKey) === '1';
|
||||
} catch (e) {
|
||||
this.localMatchAlternativesCollapsed = false;
|
||||
}
|
||||
|
||||
return this.localMatchAlternativesCollapsed;
|
||||
},
|
||||
|
||||
setLocalMatchAlternativesCollapsed(collapsed) {
|
||||
this.localMatchAlternativesCollapsed = Boolean(collapsed);
|
||||
try {
|
||||
localStorage.setItem(
|
||||
this.localMatchAlternativesCollapsedStorageKey,
|
||||
this.localMatchAlternativesCollapsed ? '1' : '0'
|
||||
);
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
renderLocalMatchesContent(missing, missingIndex = 0) {
|
||||
const allMatches = missing.matches || [];
|
||||
const filteredMatches = allMatches.filter(m => m.confidence >= 70);
|
||||
@@ -1804,12 +1828,13 @@ export const searchPanelMethods = {
|
||||
if (perfectMatches.length > 0 && otherMatches.length > 0) {
|
||||
const matchId = `more-matches-${missing.node_id}-${missing.widget_index}`;
|
||||
const altLabel = `Alternatives (${otherMatches.length})`;
|
||||
html += `<button type="button" class="mr-local-alternatives-toggle" aria-expanded="true" onclick="window.MLToggleHidden('${matchId}', this, '${altLabel}', '${altLabel}')">`;
|
||||
const alternativesCollapsed = this.areLocalMatchAlternativesCollapsed();
|
||||
html += `<button type="button" class="mr-local-alternatives-toggle" data-ml-preference="local-match-alternatives" aria-expanded="${alternativesCollapsed ? 'false' : 'true'}" onclick="window.MLToggleHidden('${matchId}', this, '${altLabel}', '${altLabel}')">`;
|
||||
html += `<span class="mr-local-alternatives-label">${altLabel}</span>`;
|
||||
html += `<span class="mr-local-alternatives-state">Hide</span>`;
|
||||
html += `<span class="mr-local-alternatives-state">${alternativesCollapsed ? 'Show' : 'Hide'}</span>`;
|
||||
html += `<span class="mr-local-alternatives-chevron" aria-hidden="true"></span>`;
|
||||
html += `</button>`;
|
||||
html += `<div id="${matchId}" class="mr-stack-sm">`;
|
||||
html += `<div id="${matchId}" class="mr-stack-sm ${alternativesCollapsed ? 'mr-hidden' : ''}">`;
|
||||
for (let mIdx = 0; mIdx < otherMatches.length; mIdx++) {
|
||||
const match = otherMatches[mIdx];
|
||||
const altBtnId = `resolve-alt-${missingIndex}-${missing.node_id}-${missing.widget_index}-${mIdx}`;
|
||||
|
||||
Reference in New Issue
Block a user