-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Description
What problem does this feature solve?
Currently, custom directives like v-focus (which focuses an inner element) won't work on a multi-root component, can we add support for this use case?
const focus = async (el, containerVisible = true) => {
if (containerVisible) {
el = el.querySelector('input') ?? el.querySelector('textarea')
await nextTick()
el?.focus()
}
}
createApp(App).directive('focus', {
mounted(el, { value }) {
focus(el, value)
},
updated(el, { value, oldValue }) {
value === oldValue || focus(el, value)
},
})<!-- `v-cascader` is a multi-root component -->
<!-- 👇 focus an inner input element currently is not possible -->
<v-cascader v-focus></v-cascader>What does the proposed API look like?
Custom directives work on multi-root components.
renatodeleao
Metadata
Metadata
Assignees
Labels
No labels