Skip to content

[Bug]: FocusScope doesn't always return focus to previous active element #2211

@nicooprat

Description

@nicooprat

Environment

Developement/Production OS: Windows 10 19043.1110
Node version: 16.0.0
Package manager: pnpm@8.6.0
Reka UI version: 2.0.0
Vue version: 3.0.0
Nuxt version: 3.0.0
Nuxt mode: universal
Nuxt target: server
CSS framework: tailwindcss@4
Client OS: Windows 10 19043.1110
Browser: Chrome 90.0.4430.212

Link to minimal reproduction

https://stackblitz.com/edit/ebfht219?file=src%2FApp.vue,index.html

Steps to reproduce

  1. Focus the "open" button and press enter
  2. The modal is focused
  3. Press tab until the "close" button is focused and press enter
  4. The "open" button is focused again ✅
  5. Repeat 1 - 3
  6. The "open" button is not focused again 🔴

Describe the bug

I'm trying to replace the focus-trap package by this FocusScope component, but I'm having a hard time figuring out why the focus is not returned to the original active element sometimes.

Maybe related? https://github.com/unovue/reka-ui/pull/519/files

Expected behavior

The original element should always be focused back.

Context & Screenshots (if applicable)

Enregistrement.de.l.ecran.2025-10-07.a.14.24.29.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions