Repository navigation
fix(ui): ask about unsaved term changes in an in-app dialog - #335
Merged
Merged
Conversation
The term dialogs used window.confirm(), which stops the page, ignores the theme and shows English text in every locale. confirmDialog() is a promise-based Bulma dialog that sits above the term dialogs. Escape and clicks outside keep the changes, and the safe button has the focus. window.confirm() remains only for when the dialog cannot be built, and the browser's own leave-page warning is unchanged. Closing is now asynchronous, so the multi-word modal releases its focus trap after closing rather than before: the user may keep editing.
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.
The term dialogs asked about unsaved changes with
window.confirm(), which stops the whole page, ignores the theme and was English in every locale.Changes
confirmDialog()andconfirmDiscardChanges()inshared/components/confirm_dialog.ts: a promise-based Bulma dialog above the term dialogs, translated in all 11 locales.word_modal,word_edit_formandmulti_word_form_store.window.confirm()remains only as a fallback if the dialog cannot be built. The browser's own leave-page warning stays native, because pages cannot replace it.close()andcancel()are now asynchronous. The multi-word modal used to release its focus trap before closing, which would have left it without one after "Keep editing", so it now releases after closing.Not changed
35 other
confirm()calls remain, such as "Delete this term?". Moving them would be a separate change.Tests
confirm_dialog.test.tscovers each way of answering, Escape not reaching the dialog underneath, Tab, focus restoring, stacking and the native fallback. The three call sites' tests and the focus trap order are updated.I also ran it in the real reader, in the dark theme, using the steps that froze the browser during production testing: an unsaved edit, then Cancel. Escape and a click outside kept the draft, and the X button then Discard closed both dialogs without saving. The translations are mine and were not reviewed by native speakers. Only the English text was seen on screen.
PHPUnit, Vitest, ESLint and TypeScript pass. Cypress passes except
24-anki-live.cy.ts, which needsnpm run anki:upand was not run.