Skip to content

Commit

Permalink
Editor: Reuse the tabbable utility to retrieve the tabbables elements…
Browse files Browse the repository at this point in the history
… in WritingFlow
  • Loading branch information
youknowriad committed Sep 16, 2017
1 parent 52c636e commit 27b4555
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions editor/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { Component } from 'element';
import { keycodes } from '@wordpress/utils';
import { keycodes, focus } from '@wordpress/utils';

/**
* Internal dependencies
Expand Down Expand Up @@ -31,14 +31,14 @@ class WritingFlow extends Component {
}

getVisibleTabbables() {
const tabbablesSelector = [
'*[contenteditable="true"]',
'*[tabindex]:not([tabindex="-1"])',
'textarea',
'input',
].join( ', ' );
const isVisible = ( elem ) => elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0;
return [ ...this.container.querySelectorAll( tabbablesSelector ) ].filter( isVisible );
return focus.tabbable
.find( this.container )
.filter( ( node ) => (
node.nodeName === 'INPUT' ||
node.nodeName === 'TEXTAREA' ||
node.contentEditable === 'true' ||
node.classList.contains( 'editor-visual-editor__block' )
) );
}

moveFocusInContainer( target, direction = 'UP' ) {
Expand Down

0 comments on commit 27b4555

Please sign in to comment.