Keeps a chart in a frame from stranding the reader when they tab back out.
A chart in an iframe swallows every key it is sent: keyboard events do not
cross a frame boundary, so while the reader is inside the chart the page
around it hears nothing. That is right while they are reading — MAIDR binds
the arrows, Space, Backspace, Page Up and Page Down itself — which leaves
Shift + Tab as the way back to the page.
Usually the browser handles that on its own: Shift + Tab at the frame's first
tab stop moves to whatever precedes the frame in the host. But when nothing
usable precedes it, focus leaves the document altogether for the browser's
own UI, and the page cannot be driven from the keyboard until the reader tabs
all the way back in. A chart on a Quarto revealjs slide is exactly that
case: the deck's own controls are not rendered, so a chart is the first thing
on the page, and from inside it no key reaches the deck.
So this service watches for Shift + Tab at the frame's first tab stop, and
steps in only when the browser would strand the reader, handing focus to
the element that holds the frame — the slide, in a deck. Where the host has
somewhere real to go, the native tab order is left exactly as it was, and Tab
in the forward direction is never touched.
Nothing happens outside a frame, and nothing here can trap a reader: if the
handoff cannot be completed, the focused element is blurred so the next
Shift + Tab does what the browser would have done in the first place.
Keeps a chart in a frame from stranding the reader when they tab back out.
A chart in an iframe swallows every key it is sent: keyboard events do not cross a frame boundary, so while the reader is inside the chart the page around it hears nothing. That is right while they are reading — MAIDR binds the arrows, Space, Backspace, Page Up and Page Down itself — which leaves Shift + Tab as the way back to the page.
Usually the browser handles that on its own: Shift + Tab at the frame's first tab stop moves to whatever precedes the frame in the host. But when nothing usable precedes it, focus leaves the document altogether for the browser's own UI, and the page cannot be driven from the keyboard until the reader tabs all the way back in. A chart on a Quarto
revealjsslide is exactly that case: the deck's own controls are not rendered, so a chart is the first thing on the page, and from inside it no key reaches the deck.So this service watches for Shift + Tab at the frame's first tab stop, and steps in only when the browser would strand the reader, handing focus to the element that holds the frame — the slide, in a deck. Where the host has somewhere real to go, the native tab order is left exactly as it was, and Tab in the forward direction is never touched.
Nothing happens outside a frame, and nothing here can trap a reader: if the handoff cannot be completed, the focused element is blurred so the next Shift + Tab does what the browser would have done in the first place.