mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-03 13:47:55 +01:00
fix(InputMenu): emit focus event (#2386)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const open = ref(false)
|
||||||
|
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
|
||||||
|
const selected = ref('Backlog')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UInputMenu
|
||||||
|
v-model="selected"
|
||||||
|
v-model:open="open"
|
||||||
|
:items="items"
|
||||||
|
@focus="open = true"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -611,6 +611,16 @@ name: 'input-menu-open-example'
|
|||||||
In this example, press :kbd{value="O"} to toggle the InputMenu.
|
In this example, press :kbd{value="O"} to toggle the InputMenu.
|
||||||
::
|
::
|
||||||
|
|
||||||
|
### Control open state on focus
|
||||||
|
|
||||||
|
You can also use the `@focus` directive to control the open state.
|
||||||
|
|
||||||
|
::component-example
|
||||||
|
---
|
||||||
|
name: 'input-menu-open-focus-example'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
### Control search term
|
### Control search term
|
||||||
|
|
||||||
Use the `v-model:search-term` directive to control the search term.
|
Use the `v-model:search-term` directive to control the search term.
|
||||||
|
|||||||
@@ -228,6 +228,10 @@ function onBlur(event: FocusEvent) {
|
|||||||
emitFormBlur()
|
emitFormBlur()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFocus(event: FocusEvent) {
|
||||||
|
emits('focus', event)
|
||||||
|
}
|
||||||
|
|
||||||
function onUpdateOpen(value: boolean) {
|
function onUpdateOpen(value: boolean) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
const event = new FocusEvent('blur')
|
const event = new FocusEvent('blur')
|
||||||
@@ -269,6 +273,7 @@ defineExpose({
|
|||||||
delimiter=""
|
delimiter=""
|
||||||
as-child
|
as-child
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
|
@focus="onFocus"
|
||||||
>
|
>
|
||||||
<TagsInputItem v-for="(item, index) in tags" :key="index" :value="(item as string)" :class="ui.tagsItem({ class: props.ui?.tagsItem })">
|
<TagsInputItem v-for="(item, index) in tags" :key="index" :value="(item as string)" :class="ui.tagsItem({ class: props.ui?.tagsItem })">
|
||||||
<TagsInputItemText :class="ui.tagsItemText({ class: props.ui?.tagsItemText })">
|
<TagsInputItemText :class="ui.tagsItemText({ class: props.ui?.tagsItemText })">
|
||||||
@@ -305,6 +310,7 @@ defineExpose({
|
|||||||
:required="required"
|
:required="required"
|
||||||
:class="ui.base({ class: props.ui?.base })"
|
:class="ui.base({ class: props.ui?.base })"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
|
@focus="onFocus"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span v-if="isLeading || !!avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
<span v-if="isLeading || !!avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
||||||
|
|||||||
Reference in New Issue
Block a user