UI: Fix tab navigation after closing addon panel#33971
Draft
Conversation
…panel When the addon panel is closed via the close button or keyboard shortcut (Alt+A), focus is now moved to the "Show addon panel" button in the toolbar. This uses the existing focusOnUIElement polling mechanism to handle the timing of React re-renders. Fixes broken tab navigation after closing the addon panel. Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tab navigation after closing addon panel
Fix tab navigation broken after closing addon panel
Mar 2, 2026
Copilot stopped work on behalf of
Sidnioulz due to an error
March 2, 2026 13:26
Sidnioulz
requested changes
Mar 2, 2026
- Make focusOnUIElement polling optional via { poll: false } option
- Return boolean (sync) or Promise<boolean> (when polling) for success
- Maintain backwards compat with boolean 2nd arg for select option
- Only move focus when it was within the panel (shortcuts.ts)
- Fall back to document.body.focus() when showAddonPanel button unavailable
- Use focusableUIElements.showAddonPanel constant in container/Panel.tsx
- Add 10 unit tests for focusOnUIElement covering all code paths
Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
Copilot stopped work on behalf of
Sidnioulz due to an error
March 2, 2026 18:02
|
View your CI Pipeline Execution ↗ for commit 787a74c
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 787a74c ☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 787a74c
☁️ Nx Cloud last updated this comment at |
Contributor
Member
|
@copilot give a comprehensive list of manual testing steps in the PR description under heading "#### Manual testing"; this is a mandatory CI requirement |
Copilot stopped work on behalf of
Sidnioulz due to an error
March 3, 2026 10:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing the addon panel (via close button or Alt+A shortcut) left focus on the now-removed DOM element, breaking keyboard navigation entirely.
After hiding the panel, focus is now moved to the "Show addon panel" toolbar button, but only when focus was within the panel at the time of closing. If the toolbar button is unavailable, focus falls back to the start of the document. When focus is elsewhere in the app (e.g. sidebar, toolbar, preview), it is left untouched.
layout.ts: AddedshowAddonPaneltofocusableUIElements; addedfocusOnUIElementtoSubAPItype; refactoredfocusOnUIElementto accept an options object with optionalpollflag (defaults totruefor backwards compatibility) and returnboolean | Promise<boolean>indicating focus successaddons.tsx: Addedid="storybook-show-addon-panel"to the toolbar buttoncontainer/Panel.tsx:toggleVisibilitynow callsfocusOnUIElementwith{ poll: false }when hiding, falling back todocument.body.focus()on failure; usesfocusableUIElements.showAddonPanelconstantshortcuts.ts:togglePanelshortcut handler checks if focus was within the panel before moving it; uses{ poll: false }and falls back todocument.body.focus()layout.test.ts: Added 10 unit tests forfocusOnUIElementcovering all code paths (no elementId, immediate focus, select options, poll/no-poll, polling success/timeout)Manual testing
Prerequisites: Run
yarn storybook:uiand open the Storybook UI in a browser.Test 1 – Close addon panel via close button, focus moves to toolbar button
Test 2 – Close addon panel via keyboard shortcut while focus is in the panel
A).Test 3 – Toggle panel via keyboard shortcut while focus is outside the panel
A).Test 4 – Re-open addon panel after closing
Test 5 – Toggle panel shortcut when panel is already hidden
A) to toggle the panel.Test 6 – Existing search shortcut still works
/) to focus the search field.selectbehavior works (text is selected)./again — verify polling still works for the search field focus.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.