From 65c32c0c51e1b514415d121330e241533e2978c7 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 3 Jan 2020 12:04:33 +0100 Subject: [PATCH] Remove useless onModeChange callback --- .../src/components/link-control/README.md | 14 -------------- .../src/components/link-control/index.js | 6 ------ .../src/components/link-control/test/index.js | 3 --- 3 files changed, 23 deletions(-) diff --git a/packages/block-editor/src/components/link-control/README.md b/packages/block-editor/src/components/link-control/README.md index 529d1f281c5673..9ce5951076d77a 100644 --- a/packages/block-editor/src/components/link-control/README.md +++ b/packages/block-editor/src/components/link-control/README.md @@ -35,20 +35,6 @@ An array of settings objects. Each object will used to render a `ToggleControl` ## Event handlers -### onChangeMode - -- Type: `Function` -- Required: No - -Use this callback to know when the LinkControl component changes its mode to `edit` or `show` -through of its function parameter. - -```es6 - { console.log( `Mode change to ${ mode } mode.` ) } -/> -``` - ### onClose - Type: `Function` diff --git a/packages/block-editor/src/components/link-control/index.js b/packages/block-editor/src/components/link-control/index.js index a2f17fa0f70dc6..ac69db9b655fe1 100644 --- a/packages/block-editor/src/components/link-control/index.js +++ b/packages/block-editor/src/components/link-control/index.js @@ -48,7 +48,6 @@ function LinkControl( { fetchSearchSuggestions, instanceId, onClose = noop, - onChangeMode = noop, onChange = noop, } ) { // State @@ -71,7 +70,6 @@ function LinkControl( { /** * Handler function which switches the mode of the component, * between `edit` and `show` mode. - * Also, it calls `onChangeMode` callback function. * * @param {string} mode Component mode: `show` or `edit`. */ @@ -83,10 +81,6 @@ function LinkControl( { if ( value && value.title && mode === 'edit' ) { setInputValue( value.title ); } - - if ( isFunction( onChangeMode ) ) { - onChangeMode( mode ); - } }; const closeLinkUI = () => { diff --git a/packages/block-editor/src/components/link-control/test/index.js b/packages/block-editor/src/components/link-control/test/index.js index c37e96302ff291..ca91c9791384c9 100644 --- a/packages/block-editor/src/components/link-control/test/index.js +++ b/packages/block-editor/src/components/link-control/test/index.js @@ -343,7 +343,6 @@ describe( 'Selecting links', () => { it( 'should hide "selected" link UI and display search UI prepopulated with previously selected link title when "Change" button is clicked', () => { const selectedLink = first( fauxEntitySuggestions ); - const spyOnEditMode = jest.fn(); const LinkControlConsumer = () => { const [ link, setLink ] = useState( selectedLink ); @@ -353,7 +352,6 @@ describe( 'Selecting links', () => { value={ link } onChange={ ( suggestion ) => setLink( suggestion ) } fetchSearchSuggestions={ fetchFauxEntitySuggestions } - onChangeMode={ spyOnEditMode( 'edit' ) } /> ); }; @@ -380,7 +378,6 @@ describe( 'Selecting links', () => { expect( searchInput ).not.toBeNull(); expect( searchInput.value ).toBe( selectedLink.title ); // prepopulated with previous link's title expect( currentLinkUI ).toBeNull(); - expect( spyOnEditMode ).toHaveBeenCalled(); } ); describe( 'Selection using mouse click', () => {