Skip to content

Conversation

@porteron
Copy link
Contributor

@porteron porteron commented May 6, 2020

Closes #16

  • Added in support for the onclose event to be passed through props. onClose is triggered in the Dropdown component when the dropdown is no longer in the expanded state
  • Add state to only enable onClose if the dropdown has ever been expanded. Prevents from firing onload
  • You can test functionality by running the storybook npm run storybook. Open the dev console and see the 'Closed' log when you expand then close the dropdown.

porteron added 2 commits May 5, 2020 19:15
…Close is triggered in the Dropdown component when the dropdown is no longer in the expanded state
@porteron
Copy link
Contributor Author

porteron commented May 6, 2020

Damn the package-lock file

@porteron
Copy link
Contributor Author

porteron commented May 6, 2020

Also looks like your Node version in your Netlify build is 2 versions behind.

Copy link
Member

@harshzalavadiya harshzalavadiya left a 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?;
Copy link
Member

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

Comment on lines 14 to +21
children?;
contentComponent;
contentProps: object;
isLoading?: boolean;
disabled?: boolean;
shouldToggleOnHover?: boolean;
labelledBy?: string;
contentProps: object;
onClose?;
contentComponent;
shouldToggleOnHover?: boolean;
Copy link
Member

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?

Comment on lines +72 to +79
onClose,
children,
contentComponent: ContentComponent,
contentProps,
isLoading,
disabled,
shouldToggleOnHover,
isLoading,
labelledBy,
contentProps,
contentComponent: ContentComponent,
shouldToggleOnHover,
Copy link
Member

Choose a reason for hiding this comment

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

Same as previous diff

Comment on lines +88 to +96
/* eslint-disable react-hooks/exhaustive-deps */
useEffect(() => {
if (expanded === true) {
enableOnClose(true);
} else if (onCloseEnabled && !expanded) {
onClose();
}
}, [expanded]);

Copy link
Member

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])

@porteron porteron changed the title Feature/onblur prop support Feature/onClose prop support May 6, 2020
@porteron
Copy link
Contributor Author

porteron commented May 6, 2020

Closing this PR for a cleaner one:
#19

@porteron porteron closed this May 6, 2020
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.

Support for onBlur and onClose events

2 participants