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

Add truthy check for the Popover component onClose prop before calling it. #17100

Merged
merged 1 commit into from Aug 20, 2019

Conversation

@aprea
Copy link
Contributor

commented Aug 20, 2019

Description

The Popover component accepts an onClose prop which is marked as not required in the component docs. Though invoking and interacting with this component without the onClose prop raises an Uncaught TypeError.

i.e.

Uncaught TypeError: onClose is not a function
    at Object.handleOnFocusOutside [as onFocusOutside] (index.js?ver=1566273997:45399)
    at PopoverDetectOutside.handleFocusOutside (index.js?ver=1566273997:45012)
    at index.js?ver=1566273997:41965

This is because the Popover component attempts to call this prop even when the current value is undefined.

This PR introduces a simple truthy to mitigate this.

How has this been tested?

This was tested locally against the latest master.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
Copy link
Contributor

left a comment

Thanks for catching this and congrats on your first contribution!

@talldan talldan merged commit 2cd5dc3 into WordPress:master Aug 20, 2019
4 checks passed
4 checks passed
Filter opened
Details
Filter opened
Details
Milestone It
Details
Travis CI - Pull Request Build Passed
Details
@aprea aprea deleted the aprea:update/popover-component-type-error branch Aug 20, 2019
@senadir senadir added this to the Gutenberg 6.4 milestone Aug 25, 2019
dd32 pushed a commit to dd32/gutenberg that referenced this pull request Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.