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

Try another approach to fixing the sibling inserter in Firefox #7530

Merged
merged 4 commits into from
Jun 26, 2018
Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions editor/components/block-list/insertion-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class BlockInsertionPoint extends Component {
this.onBlurInserter = this.onBlurInserter.bind( this );
this.onFocusInserter = this.onFocusInserter.bind( this );
this.onClick = this.onClick.bind( this );
this.onMouseDown = this.onMouseDown.bind( this );
}

onFocusInserter( event ) {
Expand Down Expand Up @@ -50,6 +51,16 @@ class BlockInsertionPoint extends Component {
}
}

onMouseDown() {
const { layout, rootUID, index, ...props } = this.props;
props.insertDefaultBlock( { layout }, rootUID, index );
props.startTyping();
this.onBlurInserter();
if ( props.onInsert ) {
this.props.onInsert();
}
}

render() {
const { isInserterFocused } = this.state;
const { showInsertionPoint, showInserter } = this.props;
Expand All @@ -63,6 +74,7 @@ class BlockInsertionPoint extends Component {
icon="insert"
className="editor-block-list__insertion-point-button"
onClick={ this.onClick }
onMouseDown={ this.onMouseDown }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just reference this.onClick here (maybe rename it to insertNewBlock or whatever) rather than duplicating the handler's code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to commandeer the PR and push directly to it. ❤️

label={ __( 'Insert block' ) }
onFocus={ this.onFocusInserter }
onBlur={ this.onBlurInserter }
Expand Down