openui / openui/open-ui

[focusgroup] Should focusgroup manage focus when a currently-focused item is removed from the tree?

Open
#1,490 2 comments 2 reactions 1 assignee View on GitHub

@janewman is already working on this.

Since Jul 30, 2026.

focusgroup
Dominant language
MDX
Stars
4.5k
Forks
226
Avg merge
2d 22h
Merged PRs (30d)
4

Description

Originally posted here: https://github.com/whatwg/html/issues/11641#issuecomment-5123686032

Feature request: focusgroup should provide an easy way to preserve focus within the list upon an item's deletion (or should preserve focus by default), also filed as https://issues.chromium.org/issues/540028209.
See minimal example at https://jsfiddle.net/7o8futqe/2/.

When a focusgroup child is deleted while it is focused, the focus is moved to the <body> node. In almost all cases where a list with arrow navigations is used and individual items are "delete-able" the desire is to focus another item in the list, so that keyboard user don't get confused (focus the next item if it a next item exists, otherwise focus the last item).

Posting example UI screenshot, where the 3dots icon in each item shows a menu that allows the user to delete the entry.

Image

Currently, custom code is needed to restore the focus after the deletion, and since focusgroup goal is to help remove custom code implemented over and over by web developers, this seems like a reasonable addition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.