Disable FocusLock when not opened in AiDiffContainer #69134
+1
−1
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.
Summary
Fixed a bug in the AI Teaching Assistant where clicking a button would cause focus to unexpectedly jump to another button. When users were prompted to press the space bar after clicking, the space key would inadvertently trigger the newly-focused button instead of having the intended behaviour.
Root Cause: The
<FocusLock>component inAiDiffContainerwas actively managing focus even when the container wasn't being interacted with. When the component state changed, FocusLock would re-evaluate focusable elements and automatically redirect focus, causing it to jump from the clicked element to other focusable elements.Solution: Added
disabled={!open}prop to theFocusLockcomponent so it only manages focus when the AI Diff container is actually open and being actively used.New behavior (Development)
In the first video, you can see:
<body>after clicking "Run"Old behavior (Production)
In the first video, you can see:
<body>Screen.Recording.2025-10-28.at.12.47.00.mov
The second video demonstrates that
FocusLockstill functions correctly when the AiDiffContainer is opened, maintaining focus within the container as intended for accessibility.Screen.Recording.2025-10-28.at.12.47.58.mov
Links
Testing story
Manual Testing:
PR Creation Checklist: