nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
3.57k stars 420 forks source link

Dropdown: clicking vs. keyboard #630

Open peterhijma opened 10 months ago

peterhijma commented 10 months ago

Perfect library.

My question is regarding the Dropdown component.

I have one item where I put this on:

click: (e) => {
  e.preventDefault();
  console.log("Hello");
},

There is a difference in behaviour:

My actual question: how can I prevent the dropdown from closing when using the keyboard?

Thanks in advance!

benjamincanac commented 10 months ago

I've been trying to achieve this for quite some time but unfortunately, the Headless UI Menu component closes the menu when pressing Enter: https://github.com/tailwindlabs/headlessui/blob/8e93cd063067bb1ad95d098655670a7d9a4d9e4a/packages/%40headlessui-vue/src/components/menu/menu.ts#L390C26-L390C26 and there is nothing we can do about it.

peterhijma commented 10 months ago

@benjamincanac thanks for checking. Should this issue be closed then?

benjamincanac commented 10 months ago

Well, I'd rather keep it open as it's not solved. Maybe Headless UI will solve this someday.