Skip to content

Commit

Permalink
Make sure when on last block focus cannot enter the block. (#37965)
Browse files Browse the repository at this point in the history
* Make sure when on last block focus cannot enter the block.

* Check if focus element is inside block and loop until it's not. Only for last block to keep it somewhat efficient.

* Make sure block is selected.

* Don't move focus forward until we're sure it's necessary.

* Reviewer suggested approach seems to work, commit.
  • Loading branch information
alexstine authored Jan 24, 2022
1 parent 000610e commit 2484854
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
let nextTabbable;

if ( navigateDown ) {
nextTabbable = focus.tabbable.findNext( blockElement );
nextTabbable = blockElement;
do {
nextTabbable = focus.tabbable.findNext( nextTabbable );
} while (
nextTabbable &&
blockElement.contains( nextTabbable )
);

if ( ! nextTabbable ) {
nextTabbable =
Expand Down

0 comments on commit 2484854

Please sign in to comment.