-
Notifications
You must be signed in to change notification settings - Fork 687
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
Correct dialog form values after submission #2960
Conversation
|
Reviewed via EDIT Account Information and EDIT Shipping Address in Checkout. Behaves as expected. UX Approved. |
@@ -180,5 +180,5 @@ Dialog.defaultProps = { | |||
confirmText: 'Confirm', | |||
confirmTranslationId: 'global.confirmButton', | |||
isModal: false, | |||
shouldUnmountOnHide: false | |||
shouldUnmountOnHide: true |
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.
This solution unmounts/destroys the component meaning we lose animations.
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.
Edit: Meant to request changes :D
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.
There are several files that did not use this prop (meaning they used the default of false
). Should we add shouldUnmountOnHide={false}
to those <Dialog>
implementations?
I also have concerns about losing the transitions. I'm not sure it was intentional otherwise I'd expect you to have removed related CSS.
Yes, great idea. I can definitely do that.
Very valid concern but we have a separate ticket (PWA-1194) to restore the close animations when |
@supernova-at Tried verification steps and Password field still not cleared - |
Lol oops, accidentally flipped that one twice. Good to go in 053b977. |
QA Approved |
Description
This ticket originally called for the submit / confirm handler to clear out form values like the reset / cancel button does.
Unfortunately, that didn't end up being viable. Take the following code addition to the
Dialog
component itself:We actually only want to reset the form when
onConfirm
is successful. When this function results in an error, we want to keep the form fields in their current state so that the user can more readily fix the problem.Unfortunately, there's no established pattern or enforcement of a return value from the
onConfirm
callback. In fact, most of the ones in the Venia storefront returnundefined
, explicitly or implicitly.It feels very heavy handed and error prone for the
Dialog
component to suggest or require such a return value from its callers.As such, I think the best approach for now is a targeted one where callers set
shouldUnmountOnHide
totrue
on theirDialog
s when they want the reset functionality. The form will be re-mounted when theDialog
reappears on screen, and the (new, updated)initialValues
will be used.To facilitate this, this PR changes the default value for the
Dialog
shouldUnmountOnHide
prop totrue
.Any instance of
Dialog
that was explicitly settingshouldUnmountOnHide
totrue
has been updated to omit that prop, and any instance ofDialog
that was missingshouldUnmountOnHide
/ relying on the default value has been updated to explicitly setshouldUnmountOnHide
tofalse
.Related Issue
Closes PWA-961.
Acceptance
Verification Stakeholders
Specification
Verification Steps
/account-information
page (My Account
>Account Information
)Screenshots / Screen Captures (if appropriate)
Checklist
Risks
Do we need to make this change anywhere else?