From ee5e7e4ad49985bce4d1bfbb92805643bc7903db Mon Sep 17 00:00:00 2001 From: apeatling Date: Mon, 17 May 2021 10:12:43 -0700 Subject: [PATCH] Move functions. --- packages/block-library/src/search/edit.js | 58 +++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js index c1607eec65d0f9..1785360e2a57f6 100644 --- a/packages/block-library/src/search/edit.js +++ b/packages/block-library/src/search/edit.js @@ -100,35 +100,6 @@ export default function SearchEdit( { } }, [ buttonPosition ] ); - const hideSearchField = () => { - searchFieldRef.current.style.width = `${ searchFieldRef.current.offsetWidth }px`; - searchFieldRef.current.style.flexGrow = '0'; - searchFieldRef.current.style.transitionDuration = `${ SEARCHFIELD_ANIMATION_DURATION }ms`; - searchFieldRef.current.style.transitionProperty = 'margin-left'; - - const offset = - searchFieldRef.current.offsetWidth + - parseInt( - window.getComputedStyle( searchFieldRef.current ).marginRight - ) + - parseInt( window.getComputedStyle( buttonRef.current ).marginLeft ); - - searchFieldRef.current.style.marginLeft = `-${ offset }px`; - }; - - const showSearchField = ( animate = true ) => { - const duration = animate ? SEARCHFIELD_ANIMATION_DURATION : 0; - - searchFieldRef.current.style.marginLeft = 0; - searchFieldRef.current.style.transitionDuration = `${ duration }ms`; - - const resetWidth = setTimeout( () => { - searchFieldRef.current.style.flexGrow = '1'; - searchFieldRef.current.style.width = `${ width }${ widthUnit }`; - clearTimeout( resetWidth ); - }, duration ); - }; - const getBlockClassNames = () => { return classnames( className, @@ -187,6 +158,35 @@ export default function SearchEdit( { }; }; + const hideSearchField = () => { + searchFieldRef.current.style.width = `${ searchFieldRef.current.offsetWidth }px`; + searchFieldRef.current.style.flexGrow = '0'; + searchFieldRef.current.style.transitionDuration = `${ SEARCHFIELD_ANIMATION_DURATION }ms`; + searchFieldRef.current.style.transitionProperty = 'margin-left'; + + const offset = + searchFieldRef.current.offsetWidth + + parseInt( + window.getComputedStyle( searchFieldRef.current ).marginRight + ) + + parseInt( window.getComputedStyle( buttonRef.current ).marginLeft ); + + searchFieldRef.current.style.marginLeft = `-${ offset }px`; + }; + + const showSearchField = ( animate = true ) => { + const duration = animate ? SEARCHFIELD_ANIMATION_DURATION : 0; + + searchFieldRef.current.style.marginLeft = 0; + searchFieldRef.current.style.transitionDuration = `${ duration }ms`; + + const resetWidth = setTimeout( () => { + searchFieldRef.current.style.flexGrow = '1'; + searchFieldRef.current.style.width = `${ width }${ widthUnit }`; + clearTimeout( resetWidth ); + }, duration ); + }; + const renderTextField = () => { return (