Skip to content

Commit

Permalink
Writing flow: fix tab into iframe (#50955)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored May 25, 2023
1 parent 2b687d0 commit 34c5d3c
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

1 comment on commit 34c5d3c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 34c5d3c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5081302763
📝 Reported issues:

Please sign in to comment.