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

Search block: fix defaults when inserted into navigation block #52342

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions packages/block-library/src/search/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import {
__experimentalUseBorderProps as useBorderProps,
__experimentalUseColorProps as useColorProps,
getTypographyClassesAndStyles as useTypographyProps,
store as blockEditorStore,
__experimentalGetElementClassName,
useSetting,
} from '@wordpress/block-editor';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect, useRef } from '@wordpress/element';
import {
ToolbarDropdownMenu,
Expand Down Expand Up @@ -67,7 +65,6 @@ export default function SearchEdit( {
setAttributes,
toggleSelection,
isSelected,
clientId,
} ) {
const {
label,
Expand All @@ -84,29 +81,6 @@ export default function SearchEdit( {
style,
} = attributes;

const insertedInNavigationBlock = useSelect(
( select ) => {
const { getBlockParentsByBlockName, wasBlockJustInserted } =
select( blockEditorStore );
return (
!! getBlockParentsByBlockName( clientId, 'core/navigation' )
?.length && wasBlockJustInserted( clientId )
);
},
[ clientId ]
);
const { __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );
useEffect( () => {
if ( ! insertedInNavigationBlock ) return;
// This side-effect should not create an undo level.
__unstableMarkNextChangeAsNotPersistent();
setAttributes( {
showLabel: false,
buttonUseIcon: true,
buttonPosition: 'button-inside',
} );
}, [ insertedInNavigationBlock ] );
const borderRadius = style?.border?.radius;
const borderProps = useBorderProps( attributes );

Expand Down