Skip to content

Commit

Permalink
Trigger typing mode when ENTER is pressed
Browse files Browse the repository at this point in the history
Splitting a block or inserting a new paragraph block by pressing ENTER
should engage typing mode.
  • Loading branch information
noisysocks committed Jan 15, 2018
1 parent 38300ff commit 394c89b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,6 @@ export default class Editable extends Component {
if ( event.shiftKey || ! this.props.onSplit ) {
this.editor.execCommand( 'InsertLineBreak', false, event );
} else {
event.stopImmediatePropagation();
this.splitContent();
}
}
Expand Down
12 changes: 6 additions & 6 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,9 @@ export class BlockListBlock extends Component {
}

maybeStartTyping() {
// We do not want to dispatch start typing if...
// - State value already reflects that we're typing (dispatch noise)
// - The current block is not selected (e.g. after a split occurs,
// we'll still receive the keyDown event, but the focus has since
// shifted to the newly created block)
if ( ! this.props.isTyping && this.props.isSelected ) {
// We do not want to dispatch start typing if state value already reflects
// that we're typing (dispatch noise)
if ( ! this.props.isTyping ) {
this.props.onStartTyping();
}
}
Expand Down Expand Up @@ -310,6 +307,9 @@ export class BlockListBlock extends Component {
createBlock( 'core/paragraph' ),
], this.props.order + 1 );
}

// Pressing enter should trigger typing mode after the content has split
this.maybeStartTyping();
break;

case UP:
Expand Down

0 comments on commit 394c89b

Please sign in to comment.