From 4c492b42f60e7a25f24eff0f99525435a625cfcb Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:38:19 +1000 Subject: [PATCH] Rename isOpen to open --- .../block-settings-menu/block-settings-dropdown.js | 10 +++++----- packages/components/src/dropdown-menu/README.md | 2 +- packages/components/src/dropdown-menu/index.tsx | 4 ++-- packages/components/src/dropdown-menu/types.ts | 2 +- packages/components/src/dropdown/README.md | 2 +- packages/components/src/dropdown/index.tsx | 4 ++-- packages/components/src/dropdown/types.ts | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js index 355869a423d716..1bd6ce620b1ace 100644 --- a/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js +++ b/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js @@ -191,22 +191,22 @@ export function BlockSettingsDropdown( { const parentBlockIsSelected = selectedBlockClientIds?.includes( firstParentClientId ); - // Only override the isOpen prop if the current block is not the one that + // Only override the `open` prop if the current block is not the one that // opened the menu. The logic here is to ensure that non-current // block menus are automatically closed when a new block menu is opened. // This is useful for cases where focus is not present in the current window. // All other behavior of the drop down menu should be otherwise unaffected. - const isOpen = + const open = ! currentClientId || openedBlockSettingsMenu === currentClientId ? undefined : false; const onToggle = useCallback( - ( localIsOpen ) => { + ( localOpen ) => { // When the current menu is opened, update the state to reflect // the new current menu. This allows all other instances of the // menu to close if they already open. - if ( localIsOpen ) { + if ( localOpen ) { setOpenedBlockSettingsMenu( currentClientId ); } }, @@ -238,7 +238,7 @@ export function BlockSettingsDropdown( { label={ __( 'Options' ) } className="block-editor-block-settings-menu" popoverProps={ POPOVER_PROPS } - isOpen={ isOpen } + open={ open } onToggle={ onToggle } noIcons menuProps={ { diff --git a/packages/components/src/dropdown-menu/README.md b/packages/components/src/dropdown-menu/README.md index 86e17235638392..8805ebd20862e5 100644 --- a/packages/components/src/dropdown-menu/README.md +++ b/packages/components/src/dropdown-menu/README.md @@ -171,7 +171,7 @@ A class name to apply to the dropdown menu's toggle element wrapper. - Required: No -### `isOpen`: `boolean` +### `open`: `boolean` Control whether the dropdown is open or not. diff --git a/packages/components/src/dropdown-menu/index.tsx b/packages/components/src/dropdown-menu/index.tsx index f97ea1114055e2..9995040a05d647 100644 --- a/packages/components/src/dropdown-menu/index.tsx +++ b/packages/components/src/dropdown-menu/index.tsx @@ -49,7 +49,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { className, controls, icon = menu, - isOpen: isOpenProp, + open: openProp, label, popoverProps, toggleProps, @@ -94,7 +94,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { return ( { diff --git a/packages/components/src/dropdown-menu/types.ts b/packages/components/src/dropdown-menu/types.ts index c802231ad4f076..808826eeea0762 100644 --- a/packages/components/src/dropdown-menu/types.ts +++ b/packages/components/src/dropdown-menu/types.ts @@ -71,7 +71,7 @@ export type DropdownMenuProps = { /** * Whether the dropdown is opened or not. */ - isOpen?: boolean; + open?: boolean; /** * A human-readable label to present as accessibility text on the focused * collapsed menu button. diff --git a/packages/components/src/dropdown/README.md b/packages/components/src/dropdown/README.md index da473c64989694..987b0dcfb218c7 100644 --- a/packages/components/src/dropdown/README.md +++ b/packages/components/src/dropdown/README.md @@ -68,7 +68,7 @@ Set this to customize the text that is shown in the dropdown's header when it is - Required: No -### `isOpen`: `boolean` +### `open`: `boolean` Control whether the dropdown is open or not. diff --git a/packages/components/src/dropdown/index.tsx b/packages/components/src/dropdown/index.tsx index 5132a3cfbc32b6..13be6bdada3f96 100644 --- a/packages/components/src/dropdown/index.tsx +++ b/packages/components/src/dropdown/index.tsx @@ -50,7 +50,7 @@ const UnconnectedDropdown = ( onClose, onToggle, style, - isOpen: isOpenProp, + open: openProp, // Deprecated props position, @@ -78,7 +78,7 @@ const UnconnectedDropdown = ( const [ isOpenState, setIsOpen ] = useObservableState( false, onToggle ); // Allow provided `isOpen` prop to override internal state. - const isOpen = isOpenProp ?? isOpenState; + const isOpen = openProp ?? isOpenState; useEffect( () => () => { diff --git a/packages/components/src/dropdown/types.ts b/packages/components/src/dropdown/types.ts index 8251528c52536c..291a40bdef53f8 100644 --- a/packages/components/src/dropdown/types.ts +++ b/packages/components/src/dropdown/types.ts @@ -60,7 +60,7 @@ export type DropdownProps = { /** * Whether the dropdown is opened or not. */ - isOpen?: boolean; + open?: boolean; /** * A callback invoked when the popover should be closed. */