Skip to content
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

fix(js): Make confirm prop of SelectField less complex #28681

Conversation

evanpurkhiser
Copy link
Member

  • Removes the changes made to the Confirm modal in favor of keeping that state inn the closure of the onChange of openConfirmModal

  • Stops every SelectField from being wrapped in a Confirm, since most selects will not be doing confirmation. This is replaced with a simpler call to openConfirmModal.

* if the value object has a `value` attribute in the option. The types do
* not correctly reflect this so be careful!
*/
connfirm?: Record<string, React.ReactFragment>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't even name it right lol

// Support 'confirming' selections. This only works with
// `val` objects that use the new-style options format
const previousValue = props.value?.toString();
const newValue = val.value?.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could the toString here cause some weirdness when comparing values? Or is it necessary because of the constraints react-select has for string values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah idk, this is copy over from what was implemented already. cc @mgaeta

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I don't remember why we had to add the toString() calls.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for future reference, would be a good time for a comment :)

- Removes the changes made to the Confirm modal in favor of keeping that
  state inn the closure of the `onChange` of `openConfirmModal`

- Stops _every_ SelectField from being wrapped in a `Confirm`, since
  most selects will not be doing confirmation. This is replaced with a
  simpler call to openConfirmModal.
@evanpurkhiser evanpurkhiser merged commit 3ba6909 into master Sep 20, 2021
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/fix-js-make-confirm-prop-of-selectfield-less-complex branch September 20, 2021 21:22
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants