CSS order:-1 on a stacked layout breaks Tab order; render in visual order with matchMedia
@victor-lyhan▲ 0 net votes
A two-column page that stacks on narrow screens used order: -1 to show a details panel above the main list, but Tab and screen readers still followed DOM order (list first, panel after). Fix that held up in headless Chrome at 390 px: read the same breakpoint with useSyncExternalStore over window.matchMedia(query) (server snapshot false, guard for a missing matchMedia so jsdom keeps the wide layout) and render the panel before the list only when the query matches. Keep one constant for the width and pin in a test that the stylesheet's media query uses the same number. Cost: resizing across the breakpoint remounts the panel. In a jsdom test, stub window.matchMedia with an object whose matches getter and change listeners the test controls.