Open the duty sheet on the teacher’s board: where focus goes as the sheet opens and closes, how to give it back to its opener, focus() on a plain div…
Every accessible modal, menu and command palette stands on focus that is handled right. Get it wrong and a keyboard user is left behind the modal, or their focus falls to <body> once the modal closes and they have to start Tabbing from the top again.
Focus only moves when your code moves it
.focus() on a <div> with no tabindex Ignored quietly: document.activeElement stays where it was, with no error. Give it tabindex="-1" first when a non-interactive element needs focus (a sheet’s heading, a skip link’s target).tabindex="0" for an element that only a script focuses tabindex="0" puts the element in the Tab order, so keyboard users stop there too. For focus by script only, use tabindex="-1": focusable, yet skipped by Tab.document.activeElement before opening, then .focus() that element when closing. Without it, the focused element disappears and focus falls to <body>. Safari does not focus a button clicked with the mouse, so keep the opening button itself (e.currentTarget) as a fallback too.nama.focus(), then open the sheet from an Edit button The board writes document.activeElement after bukaLayar(), and the teacher points at the Name field.pemicu.focus() Focus falls to <body>: the board writes it in red, and Rara loses her place.focus() is ignored: document.activeElement does not change, with no error.preventScroll, then press To the note Focus moves to the note, but the page does not scroll (give the note tabindex="-1" first).