-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: add navigation confirmation when builder fields are dirty #4670
feat: add navigation confirmation when builder fields are dirty #4670
Conversation
a7ab3c5
to
84b378a
Compare
Regarding the UX itself, is there any particular reason to have different modals in each case? Since there are two sets of modals (one for navigation and one for changing the active state within the same route), I wonder if users would have the (incorrect) impression that "discarding changes" means different things for each modal. For instance (and this is just my intuition - feel free to comment if you don't think so), if i click out of a dirty field, I might think that the "You have unsaved changes" modal will discard my changes to the current active field. But if let's say i've been working on my form and I try to navigate away, seeing a different modal ("Discard changes?") I might be worried that there are other changes to the form that aren't yet saved. |
|
...res/admin-form/create/builder-and-design/BuilderAndDesignContent/BuilderAndDesignContent.tsx
Outdated
Show resolved
Hide resolved
frontend/src/features/admin-form/create/builder-and-design/useFieldBuilderStore.tsx
Show resolved
Hide resolved
...-and-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/common/useEditFieldForm.ts
Outdated
Show resolved
Hide resolved
frontend/src/features/admin-form/create/builder-and-design/useDesignStore.tsx
Show resolved
Hide resolved
frontend/src/features/admin-form/create/builder-and-design/useFieldBuilderStore.tsx
Outdated
Show resolved
Hide resolved
…vigation # Conflicts: # frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/FieldRow/FieldRowContainer.tsx
agree it might be confusing, let's stick with the 'You have unsaved changes' modal, which is easier English to understand |
removes the possibility of passing the function directly into a on* handler which causes the pending argument to be truthy
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.
lgtm
Problem
This PR adds a navigation confirmation on navigation and change of field when the field being currently edited is dirty. The possible navigation cases are covered below:
Any permutation (start page -> field, field -> field, end page -> start page) will trigger a render of a new
DirtyModal
component if the fields are dirty. This was achieved by storing pending states in the respective stores and context, subscribing to a newly exposedisDirty
selector infieldBuilderStore
.Any route navigation change will also trigger a similar
NavigationPrompt
modal.Closes #4304
Solution
Breaking Changes
Features:
NavigationPrompt
modal component to show navigation confirmation modal when condition is trueisDirty
constant is true.useDesignStore
,useFieldBuilderStore
,CreatePageSidebarContext
to be responsive to dirty field state.Screenshots
CreatePage stories should now have the behaviour, but here is a gif in case that is hard to navigate.