-
-
Notifications
You must be signed in to change notification settings - Fork 10
Return focus to gloss field after note dialog interaction #4037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit 0b87f65. The issue was that Material-UI Dialog automatically returns focus to the triggering element after closing, which was overriding our focus change. Now using |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit 99ea0ee. Added |
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4037 +/- ##
==========================================
+ Coverage 74.66% 74.69% +0.02%
==========================================
Files 293 293
Lines 10890 10895 +5
Branches 1364 1365 +1
==========================================
+ Hits 8131 8138 +7
+ Misses 2362 2359 -3
- Partials 397 398 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit 3b9c290. Made |
@copilot The delay was unnecessary. Focus was successfully moving to the gloss field. However, |
…oration Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit f7a188c. Removed the setTimeout delay and added explicit blur of the active element when opening the dialog. The issue was that the button retained focus from being clicked, so even with |
|
|
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit 24013a7. The tests now use |
imnasnainaec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imnasnainaec reviewed 1 of 2 files at r6, 2 of 3 files at r7, 1 of 1 files at r8, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @copilot)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements focus restoration to the gloss field after interacting with the note button in the NewEntry component, matching the existing behavior of the pronunciation buttons.
Key Changes:
- Added
onExitedcallback prop toEditTextDialogto trigger actions after dialog transition completes - Modified
NoteButtonto blur itself when opening the dialog (preventing unintended focus restoration) and pass through theonExitedcallback - Connected the focus restoration in
NewEntryby passing a callback that focuses the gloss field when the note dialog closes - Added comprehensive tests to verify focus returns to gloss field after both canceling and confirming note entry
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/components/Dialogs/EditTextDialog.tsx |
Added optional onExited prop passed to Dialog's transition slotProps for post-close callbacks |
src/components/Buttons/NoteButton.tsx |
Added handleOpen to blur button before opening dialog, and passed onExited prop through to EditTextDialog |
src/components/DataEntry/DataEntryTable/NewEntry/index.tsx |
Connected focus restoration by passing callback to focus gloss field via NoteButton's onExited prop |
src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx |
Added two tests verifying focus returns to gloss after canceling and confirming note dialog, using waitFor for async transition handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Plan to Return Focus to Gloss After Adding Note
Changes Made
EditTextDialog Component (
src/components/Dialogs/EditTextDialog.tsx)onExitedprop to interfaceonExitedto Dialog'sslotProps.transition.onExited(MUI v6 API)disableRestoreFocusto always true to prevent focus from returning to the triggering buttonNoteButton Component (
src/components/Buttons/NoteButton.tsx)onClicktoonExitedfor clarityhandleOpenfunction that blurs the active element before opening dialogprops.onExiteddirectly toEditTextDialog'sonExitedprop() => setNoteOpen(false)NewEntry Component (
src/components/DataEntry/DataEntryTable/NewEntry/index.tsx)FOCUS_DELAY_MSconstant (delay was unnecessary)onExited={() => focus(FocusTarget.Gloss)}without setTimeoutPronunciationsFrontendcomponentTests (
src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx)waitForto properly wait for the asynconExitedcallback to fire after dialog transitionfocusInputis called when the dialog closesRoot Cause Analysis
Material-UI Dialog has built-in focus restoration that returns focus to the triggering element after the dialog closes. While
disableRestoreFocusprevents the Dialog component from managing focus, the button itself retains focus from when it was clicked.The solution:
disableRestoreFocusto prevent the dialog from managing focusslotProps.transition.onExited(MUI v6 API) for the callbackhandleOpen) so it doesn't retain focuswaitForin tests to wait for the async transition callbackThis combination ensures focus moves directly to the gloss field without any intermediate stops at the button.
Verification Results
✅ All linting checks pass
✅ All NewEntry tests pass (8/8)
✅ All NoteButton tests pass (2/2)
✅ CodeQL security scan found no vulnerabilities
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
This change is