Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Web component DropdownMenu and Select arrow key bug #1564

Closed
pmairoldi opened this issue Jan 18, 2025 · 1 comment · Fixed by #1570
Closed

[Bug]: Web component DropdownMenu and Select arrow key bug #1564

pmairoldi opened this issue Jan 18, 2025 · 1 comment · Fixed by #1570
Labels
bug Something isn't working

Comments

@pmairoldi
Copy link
Contributor

Environment

Node version: v18.20.3
Radix Vue version: 1.9.12
Vue version: 3.5.13

Client OS: macOS 12.7.6
Browser: Chromium Engine Version 131.0.6778.265

Link to minimal reproduction

https://stackblitz.com/edit/nexbpjt8-wvsqpwgv?file=src%2Fcustom-elements%2FCustomElement.ce.vue

Steps to reproduce

Related issue #1003

  • Create a custom element with a DropdownMenu or a Select
  • Make sure the Portal has the prop disabled set to true
  • Click toggle to open DropdownMenuContent or SelectContent
  • Press down arrow to navigate the options

This can be tested using the reproduction link.

Describe the bug

Since the component is inside a custom element it seems like the current activeElement is incorrect. From my tests document.activeElement when using inside a custom-element is the custom element itself rather than the selected option.

I think the follow code may be the problem line may be the problem:

It seems like this has already been addressed for radio groups so possibly the same fix could work #1314

Expected behavior

I expect the arrow key navigation to work the same inside a custom element as it does outside.

Context & Screenshots (if applicable)

Screen.Recording.2025-01-17.at.8.39.11.PM.mov
@pmairoldi pmairoldi added the bug Something isn't working label Jan 18, 2025
@zernonia
Copy link
Member

Thanks for the issue @pmairoldi ! Thanks again for reporting similar issue as previous.
I believe the solution should be quite the same. PR is welcomed!

pmairoldi added a commit to pmairoldi/radix-vue that referenced this issue Jan 21, 2025
pmairoldi added a commit to pmairoldi/radix-vue that referenced this issue Jan 27, 2025
zernonia pushed a commit that referenced this issue Jan 27, 2025
…thin custom elements (#1570)

* fix(#1564): introduce useActiveElement function

* fix(#1564): replace document.activeElement with useActiveElement

* fix(#1564): rename useActiveElement to getActiveElement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants