Repository navigation
Keep keyboard focus in the config store's delete confirmation - #177
Merged
Merged
Conversation
The delete confirmation is a second ComposedModal stacked over the store. When it opened and focused its Cancel button, the store's focus wrap saw focus leave for an element after it and pulled it back to the store's Close button. Focus stayed behind the dialog with the Close tooltip open, Tab cycled through the store, and the first Escape only closed the tooltip. List the confirmation in the store's selectorsFloatingMenus so the store lets focus move into it; the confirmation's own wrap keeps Tab inside it. When the confirmation closes, return focus to the row's Delete button, or to the store body after a delete removes that row, so Tab stays in the store instead of escaping to the page behind it.
jbellister-slac
approved these changes
Nov 12, 2026
jbellister-slac
left a comment
Contributor
There was a problem hiding this comment.
Looks good, no blocking issues, two small inline notes.
Checked locally by claude at 1ac39af against Carbon 1.108.0:
- The store's blur handler skips its focus wrap when the new target matches
selectorsFloatingMenus, so listing the confirmation's class there is the supported way to exempt it. - The focus-return cleanup runs after the commit that closes the confirmation, so the confirmation's own wrap is already off.
- The test claims in the description hold: removing
selectorsFloatingMenusfails the new test, and removing the focus return fails both the new test and the delete test. - Full suite (409 tests),
pnpm lintandtsc -bpass.
Address review feedback on the delete-confirmation focus fix: - When the confirmation closes, fall back to the store body if the row's Delete button is still connected but disabled, not only when it's gone. focus() on a disabled button does nothing, so focus would stay on the hidden confirmation if the list reload ever lands in a later render. - Name the store's scrolling region "Config store contents" so it doesn't repeat the dialog title for screen reader users.
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.
Description
src/components/ConfigStoreModal.tsx:config-store-delete-confirmclass, and the store'sComposedModallists it inselectorsFloatingMenus. The store's focus wrap then lets focus move into the confirmation, and the confirmation's own wrap keeps Tab inside it.aria-label="Config store", since it can receive focus.src/components/ConfigStoreModal.test.tsx: a regression test for opening the confirmation and closing it with Escape, plus a focus check on the existing delete test.Motivation
The delete confirmation is a second
ComposedModalstacked over the store (from 9a93996). When it opened and focused its Cancel button, the store's Carbon focus wrap (handleBlur→wrapFocus) saw focus leave for an element after it in the DOM and moved it back to the store's first button, the Close (X) button. So with the dialog open:Separately, closing the confirmation left focus on the hidden dialog, so the next Tab left the store for the page behind it.
Now, when the confirmation opens, focus is on Cancel (Carbon's default for danger modals). Tab and Shift+Tab cycle through Close, Cancel and Delete. One Escape closes the dialog, and focus returns to the store.
After Cancel or Escape, the row's Delete icon button gets focus back and Carbon shows its "Delete" tooltip, as it does for any focused icon button. Closing the store from there takes two Escapes, the same as before the confirmation opened.
About the test
jsdom differs from a browser here in three ways, and the test works around each one:
offsetParentis alwaysnull, and Carbon's focus wrap skips elements without one, so the store's wrap could never move focus. The test stubs it toparentElement.blurhandler moves focus, jsdom lets the outerfocus()call win, while Chrome keeps the inner one. SoactiveElementends on Cancel even without the fix. The test also checks that nofocusinlands outside the confirmation, and that check fails without the fix.scrollIntoViewis missing. Carbon's modal calls it when focus moves inside a scrollingModalBody, so it is stubbed for every test in the file.Removing
selectorsFloatingMenusfails the new test. Removing the focus-return effect fails both the new test and the delete test.Overlap with #129
#129 (still open) rewrites
ConfigStoreModal.tsxand keeps this dialog structure. Whichever PR merges second needs these four changes ported by hand: the class on the confirmation,selectorsFloatingMenuson the store, recording the Delete button that opened the confirmation, and the effect that returns focus when it closes.Screenshots
Checked live against a local Canopy backend. Main: focus on the store's X, "Close" tooltip open, Tab cycling the store. This branch: focus on Cancel (with focus ring), Tab cycling within the confirmation, focus back on the row button after Escape and Cancel, and on the store body after a delete.
Pre-merge checklist
npm test)npm run lint)