Repository navigation
fix(ui): ask in the page before a link leaves a changed form - #340
Merged
Merged
Conversation
Two handlers passed the LanguageId value object straight to the JSON
encoder, so clients received "langId": {}.
Only term forms had the in-app dialog, so every other form fell back to the browser's prompt on a plain link. A click on a link that would replace the page now opens the dialog on all of them. The native prompt stays for what a page cannot intercept: closing or reloading the tab.
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.
Follows the 3.8.1 live test.
In-app prompt on full-page forms
Only term forms used the in-app dialog. On every other form, a plain link such as Cancel fell back to the browser's prompt, which goes against keeping the native one for emergencies.
lwtFormCheck.askBeforeExit()now also installs one click listener on the document. On a changed form, a click on a link that would replace the page opens the in-app dialog. Keeping stays on the form; discarding clears the state and follows the link, so the native prompt does not appear as well.The listener runs when the click reaches the document, so a link whose own handler cancelled it never asks. It also ignores in-page anchors, new tabs, downloads, non-web links and modified clicks.
The dialog says "this page", with a new
dialog.leave_messagein all 11 locales, because the existing message says "this term".The native prompt stays for closing or reloading the tab, and for scripted navigation such as the navbar language picker and the logout form.
langIdin the term APIGET /api/v1/terms/{id}returned"langId": {}, because two handlers passed theLanguageIdobject to the JSON encoder. Both now return the number.Testing
24-anki-live, no Anki), none failed.