Skip to content

Conversation

rdjanuar
Copy link
Contributor

@rdjanuar rdjanuar commented Aug 11, 2025

πŸ”— Linked issue

Resolves #4690

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@rdjanuar rdjanuar changed the title fix(InputMenu): issue focusing element using label fix(InputMenu): issue focusing element using UFormField Aug 11, 2025
Copy link

pkg-pr-new bot commented Aug 11, 2025

npm i https://pkg.pr.new/@nuxt/ui@4696

commit: 69c64f3

Comment on lines 85 to 93
compoundVariants: [...(options.theme.colors || []).map((color: string) => ({
color,
variant: ['outline', 'subtle'],
class: `focus:ring-2 focus:ring-inset focus:ring-${color}`
})), {
color: 'neutral',
variant: ['outline', 'subtle'],
class: 'focus:ring-2 focus:ring-inset focus:ring-inverted'
}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser behavior when focusing button via label will fire :focus instead of :focus-visible,
you can check this out https://stackblitz.com/edit/stackblitz-starters-ew5qzrui?description=HTML/CSS/JS%20Starter&file=script.js,styles.css,index.html&terminalHeight=10&title=Static%20Starter

@benjamincanac benjamincanac changed the title fix(InputMenu): issue focusing element using UFormField fix(InputMenu): attach id on the input to handle focus in a FormField Aug 14, 2025
Copy link
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdjanuar I've updated your PR to focus on the id.

Would you mind opening a new issue/PR regarding the focus classes?

@rdjanuar
Copy link
Contributor Author

Okee @benjamincanac , i make other PR for handling focus classes

@benjamincanac
Copy link
Member

Yeah I'd like a reproduction as I'm not sure to understand why you want to change this.

However, we still need to fix the Select component to resolve the linked issue πŸ€”

@rdjanuar
Copy link
Contributor Author

Copy link
Member

benjamincanac commented Aug 14, 2025

It doesn't really matter as the focus would be taken by the popup if it worked anyway. You can check the SelectMenu on the playground: /components/form.

@rdjanuar
Copy link
Contributor Author

if you take a look for native select. select component will focus and not show popup list @benjamincanac

@rdjanuar
Copy link
Contributor Author

@benjamincanac
Copy link
Member

benjamincanac commented Aug 14, 2025

Indeed, we could change the focus-visible to focus inside input.ts (which select.ts inherits from) but it still doesn't fix the issue as the Select renders a <button>

EDIT: Nevermind, it works but now I wonder if SelectMenu should not have the same behavior..

@rdjanuar
Copy link
Contributor Author

It's fix the issue, native label can focus button via attr label for and attr button id. so when user click label browser automaticly focus the button @benjamincanac

@rdjanuar
Copy link
Contributor Author

rdjanuar commented Aug 14, 2025

for SelectMenu i think it's came from upstream since when we focusing button via label it's trigger the popover list.
@benjamincanac

Edit:

And i think it's follow Combobox WAI-ARIA design pattern.

https://github.com/unovue/reka-ui/blob/dc921b26846bc77ce77fcc42d94eea8f45c8db74/packages/core/src/Combobox/ComboboxTrigger.vue#L31-L44

@benjamincanac benjamincanac changed the title fix(InputMenu): attach id on the input to handle focus in a FormField fix(Select/InputMenu): handle focus via label inside a FormField Aug 14, 2025
@benjamincanac
Copy link
Member

Ok now I understand why you added those classes in the first place, took a while sorry about that! What do you think of latest commit 69c64f3?

@rdjanuar
Copy link
Contributor Author

Look good to me, the :focus only applied on select theme @benjamincanac

@benjamincanac
Copy link
Member

I still think it would be best for the Select to open when clicking on the label like on https://ui.shadcn.com/docs/components/select#form (it doesn't on https://www.shadcn-vue.com/docs/components/select.html#form) but that's an issue for Reka UI I guess.

@rdjanuar
Copy link
Contributor Author

shadcn use combobox anyway, if we want 1:1 to SelectMenu we sould rewrite the component
@benjamincanac

Screenshot 2025-08-14 at 17 10 37

@rdjanuar
Copy link
Contributor Author

you can take a look ark-ui @benjamincanac
https://ark-ui.com/docs/components/select

@benjamincanac benjamincanac merged commit 55dbcd2 into nuxt:v3 Aug 14, 2025
6 checks passed
@benjamincanac benjamincanac added the v3 #1289 label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select/InputMenu]: Focus via label not working inside FormField
2 participants