Skip to content

Don't steal focus from the layout picker during arrow-key layout stepping [#1026]#1340

Open
milosde111 wants to merge 1 commit into
e35dev:mainfrom
milosde111:fix-layout-picker-arrow-key-focus
Open

Don't steal focus from the layout picker during arrow-key layout stepping [#1026]#1340
milosde111 wants to merge 1 commit into
e35dev:mainfrom
milosde111:fix-layout-picker-arrow-key-focus

Conversation

@milosde111

Copy link
Copy Markdown
Contributor

Summary

Fixes two keyboard correctness bugs in the layout-first picker that remain after #1295 (arrow-key operation) and #1300 (roving tabindex). Without these fixes, arrow-key layout browsing is broken: focus leaves the picker mid-step and navigation keys bubbling from nested label content can change the selection unintentionally.

Problem

After #1295 and #1300, a keyboard user can step through interview / solo / panel with arrow keys and Home/End while the picker acts as a single tab stop. Two issues remain:

  1. Focus is stolen mid-step. applyLayout() always auto-focuses a newly visible or blocking slot (e.g. Guest 2 when stepping to panel). That runs before the picker handler refocuses the next layout option, briefly routing focus into the canvas and announcing slot state while the creator is still browsing layouts.

  2. Bubbled navigation keys can step layouts. The picker keydown handler does not check event.target, so an arrow key bubbling from nested label content inside a layout button can trigger layout stepping — the same failure mode fixed for placed-video move in Don't let the placed-video keyboard handler hijack its child controls… #1285.

Solution

No new UI, dependencies, or live-region copy. Pointer-driven layout selection and placement-focus behavior are unchanged.

Test plan

  • node preview/layout-first.test.js — arrow-key stepping to panel keeps focus on the picker; bubbled keys from nested labels are ignored
  • node preview/layout-first-placement-focus.test.js — click/programmatic layout switch still auto-focuses the correct slot
  • npm test

Related

Updated the applyLayout function to accept an options parameter, allowing control over focus behavior during layout changes. Added logic to maintain focus on the picker during arrow-key navigation, preventing unwanted focus shifts to newly visible slots. Updated tests to verify that focus remains on the picker and that nested elements do not trigger layout changes. This improves accessibility and user experience when navigating layouts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant