Skip to content

Commit

Permalink
Turn off content editable before calling getClosestTabbable
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 14, 2024
1 parent 55d09d3 commit 4c2ec17
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ export function getClosestTabbable(
}

// Skip focusable elements such as links within content editable nodes.
if (
node.isContentEditable &&
node.contentEditable !== 'true' &&
! node.getAttribute( 'tabindex' )
) {
if ( node.isContentEditable && node.contentEditable !== 'true' ) {
return false;
}

Expand Down Expand Up @@ -283,6 +279,7 @@ export default function useArrowNav() {
( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&
! keepCaretInsideBlock
) {
node.contentEditable = false;
const closestTabbable = getClosestTabbable(
target,
isReverse,
Expand All @@ -291,7 +288,6 @@ export default function useArrowNav() {
);

if ( closestTabbable ) {
node.contentEditable = false;
placeCaretAtVerticalEdge(
closestTabbable,
// When Alt is pressed, place the caret at the furthest
Expand All @@ -307,12 +303,12 @@ export default function useArrowNav() {
isHorizontalEdge( target, isReverseDir ) &&
! keepCaretInsideBlock
) {
node.contentEditable = false;
const closestTabbable = getClosestTabbable(
target,
isReverseDir,
node
);
node.contentEditable = false;
placeCaretAtHorizontalEdge( closestTabbable, isReverse );
event.preventDefault();
}
Expand Down

0 comments on commit 4c2ec17

Please sign in to comment.