feat(manager): warn when closing or leaving with unsaved changes (Resources, Elements, Files)#16848
Open
Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Open
feat(manager): warn when closing or leaving with unsaved changes (Resources, Elements, Files)#16848Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Conversation
43271be to
dc5a4e7
Compare
…ources, Elements, Files) - Use isDirty() for beforeunload in MODx.FormPanel onReady so any form change triggers the warning without requiring field blur; remove duplicate handler from resource panel. - On left sidebar tab switch (Resources/Elements/Files), confirm when content has a dirty form; add hasDirtyContentForm() on layout. - On Cancel button (toolbar redirect), confirm when form panel is dirty so Elements and Files match Resource behavior. Resolves modxcms#16277
dc5a4e7 to
a82cbf7
Compare
Collaborator
|
@Ibochkarev - I'll take a look at this soon. A couple things:
|
Collaborator
Author
Done — replaced var with const/let in the PR-touched code and used === for the trash tab id. |
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.
What does it do?
MODx.FormPanel.onReady, whenconfirm_navigationis on, setswindow.onbeforeunloadto return the unsaved-changes message only whenthis.isDirty(), so the warning triggers on any form change (no field blur required). Removes the duplicate handler from the resource panel that relied onwarnUnsavedChanges.hasDirtyContentForm()helper on the layout.handleClickpath for URL redirect (e.g. Cancel), checks the page form panel forisDirty()and shows the same confirm before callingMODx.loadPage, so Elements and Files get the same behavior as Resources.Why is it needed?
Closing or leaving a changed resource sometimes showed a warning only when the field had lost focus, and the warning did not apply to Elements or Files. This makes the behaviour consistent: any unsaved change triggers a warning when leaving (browser close/refresh), switching the left tab, or clicking Cancel, for Resources, Elements, and Files.
How to test
Related issue(s)/PR(s)
Resolves #16277