Skip to content

Commit

Permalink
Search block: Remove unnecessary useEffects
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Jul 11, 2023
1 parent e6c4f7e commit ece768c
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions packages/block-library/src/search/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,6 @@ export default function SearchEdit( {
defaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },
} );

useEffect( () => {
if ( hasOnlyButton && ! isSelected ) {
setAttributes( {
isSearchFieldHidden: true,
} );
}
}, [ hasOnlyButton, isSelected, setAttributes ] );

// Show the search field when width changes.
useEffect( () => {
if ( ! hasOnlyButton || ! isSelected ) {
return;
}

setAttributes( {
isSearchFieldHidden: false,
} );
}, [ hasOnlyButton, isSelected, setAttributes, width ] );

const getBlockClassNames = () => {
return classnames(
className,
Expand Down Expand Up @@ -263,6 +244,10 @@ export default function SearchEdit( {
};

const renderTextField = () => {
if ( hasOnlyButton && ! isSelected ) {
return;
}

// If the input is inside the wrapper, the wrapper gets the border color styles/classes, not the input control.
const textFieldClasses = classnames(
'wp-block-search__input',
Expand Down

0 comments on commit ece768c

Please sign in to comment.