Skip to content

Commit

Permalink
Components: limit Dropdown cleanup to renders where the menu has ac…
Browse files Browse the repository at this point in the history
…tually been opened (#41604)

* confirm dropdown is open before closing it during cleanup

* Dropdown: update changelog

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
  • Loading branch information
chad1008 and ciampo authored Jun 14, 2022
1 parent 6bf86eb commit 3c619fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
- `CustomGradientBar` updated to satisfy `react/exhuastive-deps` eslint rule ([#41463](https://github.com/WordPress/gutenberg/pull/41463))
- `TreeSelect`: Convert to TypeScript ([#41536](https://github.com/WordPress/gutenberg/pull/41536)).
- `FontSizePicker`: updated to satisfy `react/exhuastive-deps` eslint rule ([#41600](https://github.com/WordPress/gutenberg/pull/41600)).
- `Dropdown`: Make sure cleanup (closing the dropdown) only runs when the menu has actually been opened.
- Enhance the TypeScript migration guidelines ([#41669](https://github.com/WordPress/gutenberg/pull/41669)).


## 19.12.0 (2022-06-01)

### Bug Fix
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default function Dropdown( props ) {

useEffect(
() => () => {
if ( onToggle ) {
if ( onToggle && isOpen ) {
onToggle( false );
}
},
[ onToggle ]
[ onToggle, isOpen ]
);

function toggle() {
Expand Down

0 comments on commit 3c619fd

Please sign in to comment.