Skip to content

Conversation

@ldelhommeau
Copy link
Contributor

@ldelhommeau ldelhommeau commented Dec 10, 2025

#1667

This is a reproduction branch about the focus isse mentionnedn in #1667 :

When using an input field inside a Dialog that dynamically updates content within the Dialog, the focus keeps switching back to DialogContent, disrupting the user experience.

What is not working

When rendering a Dialogcomponent (or anything that can be teleported) into the shadow root.
Then rendering another component that will update the DOM (here a combobox opening a list) at some point.
If we have the focus on the inner component (e.g. combobox) when the DOM is updated, we loose the focus.

How to reproduce

Expected behaviour

The focus should not be lost.
Here is an example of how it should behave.

Note

Here everything is teleported into the body so it's working. It would be nice to have it working inside the shadow-root:

Screen.Recording.2025-12-10.at.11.41.27.mp4

Faulty behaviour

Here, everything is mounted into shadow-root, the portal target as well. So the Dialog overlay and content will mount inside the portal-target within shadow root. The Combobox will be mounted inside the Dialog content, and its list will be rendered inline.
The focus is lost when we start typing and the list is shown:

Screen.Recording.2025-12-10.at.11.40.14.1.mp4

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2331

commit: dc77f08

@ldelhommeau ldelhommeau force-pushed the test/shadow-root-focus-issue branch from 1ebd207 to 30fc625 Compare December 23, 2025 12:01
@ldelhommeau ldelhommeau changed the title test(shadow-dom): combobox within Dialog and in shadow root breaks focus test(focus-scope): shadow root issue example Dec 23, 2025
@ldelhommeau ldelhommeau force-pushed the test/shadow-root-focus-issue branch from 30fc625 to dc77f08 Compare January 12, 2026 13:19
@ldelhommeau ldelhommeau deleted the test/shadow-root-focus-issue branch January 14, 2026 16:13
@ldelhommeau ldelhommeau restored the test/shadow-root-focus-issue branch January 14, 2026 16:25
@ldelhommeau ldelhommeau reopened this Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant