Files
breadcrumb-the-shire/web/js/components/app-bulk-selection.js
fs d9f07dcd63 fix: web/ quick wins — CSS cleanup, ARIA tabs, and file header comments
CSS:
- Remove duplicate li::before block in app-search.css
- Fix typo: search-reuslt → search-result in app-search.css
- Remove commented-out CSS rules in app-flash.css
- Add descriptive header comment to all 27 CSS component files

JS:
- Complete WAI-ARIA Tabs pattern: generate IDs, add aria-controls on
  tab buttons and aria-labelledby on tab panels (app-tabs.js)
- Add JSDoc header comments to ~33 JS files (core + components)
- Add explanatory block comment to app-boot.js (why classic IIFE)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 22:21:37 +01:00

40 lines
1.2 KiB
JavaScript

/**
* Shows/hides bulk action buttons based on Grid.js row selection state.
*/
import { warnOnce } from '../core/app-dom.js';
export function bindBulkVisibility({
containerSelector,
buttonSelector,
selectedRowSelector = '.gridjs-tr-selected'
} = {}) {
const container = document.querySelector(containerSelector);
const buttons = Array.from(document.querySelectorAll(buttonSelector));
if (!container || !buttons.length) {
if (!container) {
warnOnce('UI_EL_MISSING', `Missing bulk container: ${containerSelector}`, { module: 'bulk-selection' });
}
if (!buttons.length) {
warnOnce('UI_EL_MISSING', `Missing bulk buttons: ${buttonSelector}`, { module: 'bulk-selection' });
}
return { update: () => {} };
}
const update = () => {
const selected = container.querySelectorAll(selectedRowSelector).length > 0;
buttons.forEach((button) => {
button.hidden = !selected;
});
};
const observer = new MutationObserver(() => update());
observer.observe(container, {
subtree: true,
attributes: true,
attributeFilter: ['class']
});
update();
return { update, destroy: () => observer.disconnect() };
}