From ad5e8d3eb88df077ba815bf70d78562900acaa81 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 15 Aug 2018 11:21:12 -0400 Subject: [PATCH] Default Block Appender: Remove redundant event handlers (#8714) --- .../default-block-appender/index.js | 15 ++++++++++++-- .../test/__snapshots__/index.js.snap | 20 ------------------- .../default-block-appender/test/index.js | 11 ---------- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/packages/editor/src/components/default-block-appender/index.js b/packages/editor/src/components/default-block-appender/index.js index fc8dd00203d93..c89ba5bf6ab2a 100644 --- a/packages/editor/src/components/default-block-appender/index.js +++ b/packages/editor/src/components/default-block-appender/index.js @@ -37,6 +37,19 @@ export function DefaultBlockAppender( { const value = decodeEntities( placeholder ) || __( 'Write your story' ); + // The appender "button" is in-fact a text field so as to support + // transitions by WritingFlow occurring by arrow key press. WritingFlow + // only supports tab transitions into text fields and to the block focus + // boundary. + // + // See: https://github.com/WordPress/gutenberg/issues/4829#issuecomment-374213658 + // + // If it were ever to be made to be a proper `button` element, it is + // important to note that `onFocus` alone would not be sufficient to + // capture click events, notably in Firefox. + // + // See: https://gist.github.com/cvrebert/68659d0333a578d75372 + return (
diff --git a/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap b/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap index 86ff2fe9f55ef..2917c9e672656 100644 --- a/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap +++ b/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap @@ -9,14 +9,6 @@ exports[`DefaultBlockAppender should append a default block when input focused 1 { expect( wrapper ).toMatchSnapshot(); } ); - it( 'should append a default block when input clicked', () => { - const onAppend = jest.fn(); - const wrapper = shallow( ); - const input = wrapper.find( 'input.editor-default-block-appender__content' ); - - expect( input.prop( 'value' ) ).toEqual( 'Write your story' ); - input.simulate( 'click' ); - - expectOnAppendCalled( onAppend ); - } ); - it( 'should append a default block when input focused', () => { const onAppend = jest.fn(); const wrapper = shallow( );