nuxt / ui

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

Emit focus event for UInput and UTextarea #1935

Closed Quasarman closed 3 months ago

Quasarman commented 3 months ago

Description

The blur event is already emitted for both components, would be nice to also emit the focus event so we do not have to bind it via a ref and some more separate logic.

Current (cumbersome) workaround:

Input:

inputRef.value.input.addEventListener('focus', () => {});

Textarea:

textareaRef.value.textarea.on('focus', () => {});

Additional context

No response

benjamincanac commented 3 months ago

Do you mean @focus on the <UInput /> doesn't work? 🤔

Quasarman commented 3 months ago

I tried It and also had a look at the source code, the focus event does not seem to be mapped.

benjamincanac commented 3 months ago

It should be as we bind everything on the input: https://github.com/nuxt/ui/blob/8eca5a0d627e22f42350a060f09c4e44b6de422f/src/runtime/components/forms/Input.vue#L13

Quasarman commented 3 months ago

Sorry my bad, seems there was something wrong with my hot reloading setup, just tried it again, it works as you mentioned.