-
-
Notifications
You must be signed in to change notification settings - Fork 95
Feature/onClose prop support #17
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
Conversation
…Close is triggered in the Dropdown component when the dropdown is no longer in the expanded state
…ed. Prevents from firing onload
|
Damn the package-lock file |
|
Also looks like your Node version in your Netlify build is 2 versions behind. |
harshzalavadiya
left a comment
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.
Hi @mnoster,
Thank you taking time to submit a PR, but can you make suggested changes,
if you can squash all commits to remove multiple comments with interactive rebase that will be nice, otherwise I'll be happy to rebase it for you before merging
| ItemRenderer?: Function; | ||
| selectAllLabel?: string; | ||
| isLoading?: boolean; | ||
| onClose?; |
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.
Instead of onClose we can give developer freedom to subscribe to both events for example perform some data fetching onOpen and do cleanup onClose so I think it will be better if we can have single simplified prop like onMenuToggle returning boolean value
| children?; | ||
| contentComponent; | ||
| contentProps: object; | ||
| isLoading?: boolean; | ||
| disabled?: boolean; | ||
| shouldToggleOnHover?: boolean; | ||
| labelledBy?: string; | ||
| contentProps: object; | ||
| onClose?; | ||
| contentComponent; | ||
| shouldToggleOnHover?: boolean; |
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's lot of unnecessary diff here and can be avoided easily can you reorder this as it was and just pass onMenuToggle prop?
| onClose, | ||
| children, | ||
| contentComponent: ContentComponent, | ||
| contentProps, | ||
| isLoading, | ||
| disabled, | ||
| shouldToggleOnHover, | ||
| isLoading, | ||
| labelledBy, | ||
| contentProps, | ||
| contentComponent: ContentComponent, | ||
| shouldToggleOnHover, |
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.
Same as previous diff
| /* eslint-disable react-hooks/exhaustive-deps */ | ||
| useEffect(() => { | ||
| if (expanded === true) { | ||
| enableOnClose(true); | ||
| } else if (onCloseEnabled && !expanded) { | ||
| onClose(); | ||
| } | ||
| }, [expanded]); | ||
|
|
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.
We can simplify this logic even more like below this might automatically remove exhaustive-deps
useEffect(() => {
onMenuToggle && onMenuToggle(expanded);
}, [expanded])|
Closing this PR for a cleaner one: |
Closes #16
npm run storybook. Open the dev console and see the 'Closed' log when you expand then close the dropdown.