mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 06:21:46 +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.
|
||||
::
|
||||
|
||||
### 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
|
||||
|
||||
Use the `v-model:search-term` directive to control the search term.
|
||||
|
||||
@@ -228,6 +228,10 @@ function onBlur(event: FocusEvent) {
|
||||
emitFormBlur()
|
||||
}
|
||||
|
||||
function onFocus(event: FocusEvent) {
|
||||
emits('focus', event)
|
||||
}
|
||||
|
||||
function onUpdateOpen(value: boolean) {
|
||||
if (!value) {
|
||||
const event = new FocusEvent('blur')
|
||||
@@ -269,6 +273,7 @@ defineExpose({
|
||||
delimiter=""
|
||||
as-child
|
||||
@blur="onBlur"
|
||||
@focus="onFocus"
|
||||
>
|
||||
<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 })">
|
||||
@@ -305,6 +310,7 @@ defineExpose({
|
||||
:required="required"
|
||||
:class="ui.base({ class: props.ui?.base })"
|
||||
@blur="onBlur"
|
||||
@focus="onFocus"
|
||||
/>
|
||||
|
||||
<span v-if="isLeading || !!avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
||||
|
||||
Reference in New Issue
Block a user