Skip to content

[focusgroup] Should elements with tabindex="-1" participate in focusgroup navigation when focused? #1358

@sb3nder

Description

@sb3nder

Issue #1314 resolved to add the focusgroupstart property, which determines which element receives focus when entering a focusgroup. This change freed up the use of tabindex="-1" for other purposes.

Option 1

In #1314, @janewman suggested:

An element with a tabindex="-1" would not be considered a focusgroup item and would not be managed by focusgroup at all.

I agree that an element with tabindex="-1" should not be reachable via directional navigation. However, I am unsure whether it should be excluded from directional navigation once it is focused by other means.

It’s not clear to me, how common the use case is for elements that are only programmatically focusable (via tabindex="-1") but should still participate in a focusgroup once focused.

Developers could still remove the tabindex on focus and reapply it on blur, while also adding the appropriate role property.


Option 2

An element with tabindex="-1" would not be reachable via directional navigation, but once focused, it would still participate in the focusgroup.

To achieve the same behavior as Option 1, focusgroup="none" must be added:

<div focusgroup="toolbar">
  <button tabindex="-1" focusgroup="none">btn</button>
</div>

For container elements, the same behavior as Option 1 cannot be achieved without introducing a new property (e.g., focusgroup="remove") or defining a special meaning for tabindex="-2".

Here, directional navigation works when the div is focused, unlike Option 1.

<div focusgroup="toolbar">
  <div tabindex="-1">
    div
    <button>btn</button>
  </div>
</div>

Adding focusgroup="none" removes both the div and the button, which does not reproduce the same behavior as only tabindex=-1 as Option 1:

<div focusgroup="toolbar">
  <div tabindex="-1" focusgroup="none">
    div
    <button>btn</button>
  </div>
</div>

If the container behavior in Option 1 is important, perhaps it could be reproduced with a different syntax, such as:

<div focusgroup="toolbar">
  <div tabindex="-1" focusgroup="remove">
    div
    <button>btn</button>
  </div>
</div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions