refactor: separate Layers panel presentation from lifecycle actions

This commit is contained in:
Sameh Khamis committed 2026-09-12 22:36:04 -07:00
1 parent 31f1923633
commit 07cf1695ff
14 files changed
+665 -398

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
/** Keep the clear action focusable while busy; the caller owns its transaction. */
export function bindClearLayersControl(button, clear) {
let destroyed = false;
const click = () => { if (!destroyed) void clear(); };
button?.addEventListener('click', click);
return {
setBusy(busy) {
if (destroyed || !button) return;
button.setAttribute('aria-disabled', String(busy));
button.setAttribute('aria-busy', String(busy));
button.setAttribute('aria-label', busy ? 'Clearing selected data layers' : 'Clear selected data layers');
},
destroy() {
destroyed = true;
button?.removeEventListener('click', click);
},
};
}