Skip to content

Commit

Permalink
Writing flow: fix tab into iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 25, 2023
1 parent f10f85f commit 8dd32e7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/block-editor/src/components/writing-flow/use-tab-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ export default function useTabNav() {
} else {
setNavigationMode( true );

const canvasElement =
container.current.ownerDocument === event.target.ownerDocument
? container.current
: container.current.ownerDocument.defaultView.frameElement;

const isBefore =
// eslint-disable-next-line no-bitwise
event.target.compareDocumentPosition( container.current ) &
event.target.compareDocumentPosition( canvasElement ) &
event.target.DOCUMENT_POSITION_FOLLOWING;
const action = isBefore ? 'findNext' : 'findPrevious';
const tabbables = focus.tabbable.find( container.current );

if ( tabbables.length ) {
const next = isBefore
? tabbables[ 0 ]
: tabbables[ tabbables.length - 1 ];

focus.tabbable[ action ]( event.target ).focus();
next.focus();
}
}
}

Expand Down

0 comments on commit 8dd32e7

Please sign in to comment.