Skip to content

Commit

Permalink
Merge pull request #3193 from WordPress/fix/arrow-key-into-textarea
Browse files Browse the repository at this point in the history
Fix/arrow key into textarea
  • Loading branch information
tiny-james authored Oct 30, 2017
2 parents 1b2c770 + 39c17b6 commit c5ebeca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions blocks/editable/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default class TinyMCE extends Component {

const { removedKeys, updatedKeys } = diffAriaProps( this.props, nextProps );
removedKeys.forEach( ( key ) =>
this.editorNode.removeAttribute( key ) );
this.editorNode.removeAttribute( key ) );
updatedKeys.forEach( ( key ) =>
this.editorNode.setAttribute( key, nextProps[ key ] ) );
this.editorNode.setAttribute( key, nextProps[ key ] ) );
}

componentWillUnmount() {
Expand Down
6 changes: 3 additions & 3 deletions editor/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ export function placeCaretAtHorizontalEdge( container, isReverse ) {
if ( includes( [ 'INPUT', 'TEXTAREA' ], container.tagName ) ) {
container.focus();
if ( isReverse ) {
container.selectionStart = 0;
container.selectionEnd = 0;
} else {
container.selectionStart = container.value.length;
container.selectionEnd = container.value.length;
} else {
container.selectionStart = 0;
container.selectionEnd = 0;
}
return;
}
Expand Down
4 changes: 2 additions & 2 deletions editor/utils/test/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ describe( 'DOM', () => {
const input = document.createElement( 'input' );
input.value = 'value';
placeCaretAtHorizontalEdge( input, true );
expect( isHorizontalEdge( input, true ) ).toBe( true );
expect( isHorizontalEdge( input, false ) ).toBe( true );
} );

it( 'should place caret at the end of the input', () => {
const input = document.createElement( 'input' );
input.value = 'value';
placeCaretAtHorizontalEdge( input, false );
expect( isHorizontalEdge( input, false ) ).toBe( true );
expect( isHorizontalEdge( input, true ) ).toBe( true );
} );
} );
} );

0 comments on commit c5ebeca

Please sign in to comment.