Skip to content

Focus trap lost when you click an item and remove it #1498

Closed
@cdeutsch

Description

@cdeutsch

Bug report

Current Behavior

If you click an item and remove it, the focus gets set to the browser's Url bar.

When you tab back into the body content, you can tab to elements that are behind the focus trap.

Expected behavior

Focus shouldn't go to the Url bar after removing an item.

If it does, you should return to the focus trap instead of elements outside it.

Reproducible example

Code:
https://codesandbox.io/s/hardcore-stitch-ne0g0n?file=/App.js

Easier to reproduce fullscreen:
https://ne0g0n.csb.app/

Additional context

Previously I've been using focus-trap-react and it didn't have the same issue. Focus doesn't go to the Url bar when items are removed, and if you manually focus the Url bar, you will return to the tab trap straight away.

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-dialog 0.1.8-rc.48
Radix Package(s) @radix-ui/react-select 0.1.2-rc.50
React n/a latest
Browser Chrome 102.0.5005.115
Operating System Mac 12.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions