Skip to content

Commit

Permalink
Patterns: Prevent convert modal closing block options menu
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Aug 16, 2023
1 parent 1180c17 commit adb1f0d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/patterns/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import PatternsManageButton from './patterns-manage-button';
export default function PatternsMenuItems( { rootClientId } ) {
return (
<BlockSettingsMenuControls>
{ ( { onClose, selectedClientIds } ) => (
{ ( { selectedClientIds } ) => (
<>
<PatternConvertButton
clientIds={ selectedClientIds }
rootClientId={ rootClientId }
onClose={ onClose }
/>
{ selectedClientIds.length === 1 && (
<PatternsManageButton
Expand Down
10 changes: 1 addition & 9 deletions packages/patterns/src/components/pattern-convert-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ import CreatePatternModal from './create-pattern-modal';
* @param {Object} props Component props.
* @param {string[]} props.clientIds Client ids of selected blocks.
* @param {string} props.rootClientId ID of the currently selected top-level block.
* @param {()=>void} props.onClose Callback to close the menu.
* @return {import('@wordpress/element').WPComponent} The menu control or null.
*/
export default function PatternConvertButton( {
clientIds,
rootClientId,
onClose,
} ) {
export default function PatternConvertButton( { clientIds, rootClientId } ) {
const { createSuccessNotice } = useDispatch( noticesStore );
const [ isModalOpen, setIsModalOpen ] = useState( false );
const canConvert = useSelect(
Expand Down Expand Up @@ -114,15 +109,12 @@ export default function PatternConvertButton( {
clientIds={ clientIds }
onSuccess={ ( pattern ) => {
handleSuccess( pattern );
onClose();
} }
onError={ () => {
setIsModalOpen( false );
onClose();
} }
onClose={ () => {
setIsModalOpen( false );
onClose();
} }
/>
) }
Expand Down

0 comments on commit adb1f0d

Please sign in to comment.