MCPcopy Create free account
hub / github.com/error311/FileRise / focusFirstInModal

Function focusFirstInModal

public/js/main.js:433–442  ·  view source on GitHub ↗
(modal)

Source from the content-addressed store, hash-verified

431}
432
433function focusFirstInModal(modal) {
434 if (!modal || !document.body.contains(modal)) return;
435 if (modal.contains(document.activeElement)) return;
436 const focusables = getFocusableElements(modal);
437 if (focusables.length) {
438 focusables[0].focus({ preventScroll: true });
439 } else {
440 modal.focus({ preventScroll: true });
441 }
442}
443
444function trapFocusInModal(modal) {
445 if (!modal || modal.__frTrapBound) return;

Callers 1

handleModalOpenFunction · 0.85

Calls 1

getFocusableElementsFunction · 0.85

Tested by

no test coverage detected