Skip to content

Conversation

@yotam-wix
Copy link
Collaborator

@yotam-wix yotam-wix commented Dec 11, 2025

Description

Fixed Picker dialog bug where on dismiss it 'remembers' the selected values.

Changelog

Picker - Fixed dialog onDismiss bug.

Additional info

Ticket 4680

@yotam-wix yotam-wix requested review from adids1221 and lidord-wix and removed request for adids1221 December 11, 2025 10:07
@lidord-wix lidord-wix requested review from M-i-k-e-l and removed request for lidord-wix December 11, 2025 14:41
@M-i-k-e-l M-i-k-e-l assigned yotam-wix and unassigned M-i-k-e-l Dec 18, 2025
@M-i-k-e-l
Copy link
Collaborator

@yotam-wix please merge master after the monorepo change 🙏

@yotam-wix yotam-wix force-pushed the picker-dialog-dismiss-bug branch from 634a5c1 to ceedda9 Compare December 18, 2025 08:54
@yotam-wix
Copy link
Collaborator Author

#rebuild

@yotam-wix
Copy link
Collaborator Author

@yotam-wix please merge master after the monorepo change 🙏

@M-i-k-e-l done

@M-i-k-e-l M-i-k-e-l assigned M-i-k-e-l and unassigned yotam-wix Dec 18, 2025
@M-i-k-e-l
Copy link
Collaborator

@yotam-wix you forgot to assign it to me, I'll look at it next week

Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

Nice work !

ref={pickerExpandable}
useDialog={useDialog || useWheelPicker}
dialogProps={DEFAULT_DIALOG_PROPS}
dialogProps={{...DEFAULT_DIALOG_PROPS, onDismiss: handleCancelAction}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're creating a new object each render

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@M-i-k-e-l Would a better solution be to create a memoized value using useMemo for this object of dialogProps that re-calculates for each change in handleCancelAction?


const cancelSelect = useCallback(() => {
handleCancelAction();
pickerExpandableRef.current?.closeExpandable?.();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This fix changes the order of topBarProps?.onCancel?.(); and pickerExpandableRef.current?.closeExpandable?.();.
Although I could not find a bug with it, it does not mean it does not break anything.
I am not saying that we have to find another solution but we should be aware of this and possibly try to find a solution that does not change the order.

[multiDraftValue]);

const cancelSelect = useCallback(() => {
const handleCancelAction = useCallback(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really know what is the difference between handleCancelAction and cancelSelect (name wise), try to think of a better name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will change it to resetSelectionState if that makes sense

@M-i-k-e-l M-i-k-e-l assigned yotam-wix and unassigned M-i-k-e-l Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants