mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 17:10:06 +00:00
feat(AssetBrowserModal): set initial focus to SearchBox (#5945)
## Summary Some quick design feedback. ## Changes 1. Fix the placeholder text so it's showing up correctly. 2. Make the SearchBox take initial focus when the modal is opened. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5945-feat-AssetBrowserModal-set-initial-focus-to-SearchBox-2846d73d365081bfb3e0cde78c827d5f) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -8,7 +8,7 @@ const meta: Meta<typeof SearchBox> = {
|
|||||||
component: SearchBox,
|
component: SearchBox,
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
argTypes: {
|
argTypes: {
|
||||||
placeHolder: {
|
placeholder: {
|
||||||
control: 'text'
|
control: 'text'
|
||||||
},
|
},
|
||||||
showBorder: {
|
showBorder: {
|
||||||
@@ -22,7 +22,7 @@ const meta: Meta<typeof SearchBox> = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
args: {
|
args: {
|
||||||
placeHolder: 'Search...',
|
placeholder: 'Search...',
|
||||||
showBorder: false,
|
showBorder: false,
|
||||||
size: 'md'
|
size: 'md'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
ref="input"
|
ref="input"
|
||||||
v-model="searchQuery"
|
v-model="searchQuery"
|
||||||
:aria-label="
|
:aria-label="
|
||||||
placeHolder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
|
placeholder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
|
||||||
"
|
"
|
||||||
:placeholder="
|
:placeholder="
|
||||||
placeHolder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
|
placeholder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
|
||||||
"
|
"
|
||||||
type="text"
|
type="text"
|
||||||
unstyled
|
unstyled
|
||||||
@@ -19,17 +19,19 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import InputText from 'primevue/inputtext'
|
import InputText from 'primevue/inputtext'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { cn } from '@/utils/tailwindUtil'
|
import { cn } from '@/utils/tailwindUtil'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
placeHolder,
|
autofocus = false,
|
||||||
|
placeholder,
|
||||||
showBorder = false,
|
showBorder = false,
|
||||||
size = 'md'
|
size = 'md'
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
placeHolder?: string
|
autofocus?: boolean
|
||||||
|
placeholder?: string
|
||||||
showBorder?: boolean
|
showBorder?: boolean
|
||||||
size?: 'md' | 'lg'
|
size?: 'md' | 'lg'
|
||||||
}>()
|
}>()
|
||||||
@@ -43,6 +45,8 @@ const focusInput = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => autofocus && focusInput())
|
||||||
|
|
||||||
const wrapperStyle = computed(() => {
|
const wrapperStyle = computed(() => {
|
||||||
const baseClasses = [
|
const baseClasses = [
|
||||||
'relative flex w-full items-center gap-2',
|
'relative flex w-full items-center gap-2',
|
||||||
|
|||||||
@@ -1944,7 +1944,7 @@
|
|||||||
"connectionError": "Please check your connection and try again",
|
"connectionError": "Please check your connection and try again",
|
||||||
"failedToCreateNode": "Failed to create node. Please try again or check console for details.",
|
"failedToCreateNode": "Failed to create node. Please try again or check console for details.",
|
||||||
"noModelsInFolder": "No {type} available in this folder",
|
"noModelsInFolder": "No {type} available in this folder",
|
||||||
"searchAssetsPlaceholder": "Search assets...",
|
"searchAssetsPlaceholder": "Type to search...",
|
||||||
"allModels": "All Models",
|
"allModels": "All Models",
|
||||||
"allCategory": "All {category}",
|
"allCategory": "All {category}",
|
||||||
"unknown": "Unknown",
|
"unknown": "Unknown",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<SearchBox
|
<SearchBox
|
||||||
v-model="searchQuery"
|
v-model="searchQuery"
|
||||||
|
:autofocus="true"
|
||||||
size="lg"
|
size="lg"
|
||||||
:placeholder="$t('assetBrowser.searchAssetsPlaceholder')"
|
:placeholder="$t('assetBrowser.searchAssetsPlaceholder')"
|
||||||
class="max-w-96"
|
class="max-w-96"
|
||||||
|
|||||||
Reference in New Issue
Block a user