diff --git a/utils/focus/focusable.js b/utils/focus/focusable.js index bdee0928f7da9f..c94de3d6544e08 100644 --- a/utils/focus/focusable.js +++ b/utils/focus/focusable.js @@ -33,7 +33,7 @@ const SELECTOR = [ 'object', 'embed', 'area[href]', - '[contenteditable]', + '[contenteditable]:not([contenteditable=false])', ].join( ',' ); /** diff --git a/utils/focus/test/focusable.js b/utils/focus/test/focusable.js index f21991936a163b..867940169a5528 100644 --- a/utils/focus/test/focusable.js +++ b/utils/focus/test/focusable.js @@ -85,6 +85,27 @@ describe( 'focusable', () => { expect( find( map ) ).toEqual( [] ); } ); + it( 'finds contenteditable', () => { + const node = createElement( 'div' ); + const div = createElement( 'div' ); + node.appendChild( div ); + + div.setAttribute( 'contenteditable', '' ); + expect( find( node ) ).toEqual( [ div ] ); + + div.setAttribute( 'contenteditable', 'true' ); + expect( find( node ) ).toEqual( [ div ] ); + } ); + + it( 'ignores contenteditable=false', () => { + const node = createElement( 'div' ); + const div = createElement( 'div' ); + node.appendChild( div ); + + div.setAttribute( 'contenteditable', 'false' ); + expect( find( node ) ).toEqual( [] ); + } ); + it( 'ignores invisible inputs', () => { const node = createElement( 'div' ); const input = createElement( 'input' );