Skip to content

Commit

Permalink
Improve tabindex logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Feb 23, 2024
1 parent a0517a9 commit e6f3bb7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,7 @@ export function RichTextWrapper(
}

const TagName = tagName;
let tabIndex;
if ( shouldDisableEditing ) {
tabIndex = 0;
} else {
tabIndex = props.tabIndex === 0 ? null : props.tabIndex;
}
const tabIndex = props.tabIndex === 0 ? null : props.tabIndex;
return (
<>
{ isSelected && (
Expand Down Expand Up @@ -394,13 +389,13 @@ export function RichTextWrapper(
props.className,
'rich-text'
) }
// Setting tabIndex to 0 is unnecessary, the element is already
// Setting tabIndex to 0 is unnecessary, if the element is already
// focusable because it's contentEditable. This also fixes a
// Safari bug where it's not possible to Shift+Click multi
// select blocks when Shift Clicking into an element with
// tabIndex because Safari will focus the element. However,
// Safari will correctly ignore nested contentEditable elements.
tabIndex={ tabIndex }
tabIndex={ shouldDisableEditing ? 0 : tabIndex }
data-wp-block-attribute-key={ identifier }
/>
</>
Expand Down

0 comments on commit e6f3bb7

Please sign in to comment.