Skip to content

Commit 0a73072

Browse files
authored
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)
1 parent e7745eb commit 0a73072

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/components/input/SearchBox.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const meta: Meta<typeof SearchBox> = {
88
component: SearchBox,
99
tags: ['autodocs'],
1010
argTypes: {
11-
placeHolder: {
11+
placeholder: {
1212
control: 'text'
1313
},
1414
showBorder: {
@@ -22,7 +22,7 @@ const meta: Meta<typeof SearchBox> = {
2222
}
2323
},
2424
args: {
25-
placeHolder: 'Search...',
25+
placeholder: 'Search...',
2626
showBorder: false,
2727
size: 'md'
2828
}

src/components/input/SearchBox.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
ref="input"
66
v-model="searchQuery"
77
:aria-label="
8-
placeHolder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
8+
placeholder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
99
"
1010
:placeholder="
11-
placeHolder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
11+
placeholder || t('templateWidgets.sort.searchPlaceholder', 'Search...')
1212
"
1313
type="text"
1414
unstyled
@@ -19,17 +19,19 @@
1919

2020
<script setup lang="ts">
2121
import InputText from 'primevue/inputtext'
22-
import { computed, ref } from 'vue'
22+
import { computed, onMounted, ref } from 'vue'
2323
2424
import { t } from '@/i18n'
2525
import { cn } from '@/utils/tailwindUtil'
2626
2727
const {
28-
placeHolder,
28+
autofocus = false,
29+
placeholder,
2930
showBorder = false,
3031
size = 'md'
3132
} = defineProps<{
32-
placeHolder?: string
33+
autofocus?: boolean
34+
placeholder?: string
3335
showBorder?: boolean
3436
size?: 'md' | 'lg'
3537
}>()
@@ -43,6 +45,8 @@ const focusInput = () => {
4345
}
4446
}
4547
48+
onMounted(() => autofocus && focusInput())
49+
4650
const wrapperStyle = computed(() => {
4751
const baseClasses = [
4852
'relative flex w-full items-center gap-2',

src/locales/en/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@
19441944
"connectionError": "Please check your connection and try again",
19451945
"failedToCreateNode": "Failed to create node. Please try again or check console for details.",
19461946
"noModelsInFolder": "No {type} available in this folder",
1947-
"searchAssetsPlaceholder": "Search assets...",
1947+
"searchAssetsPlaceholder": "Type to search...",
19481948
"allModels": "All Models",
19491949
"allCategory": "All {category}",
19501950
"unknown": "Unknown",

src/platform/assets/components/AssetBrowserModal.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<template #header>
2424
<SearchBox
2525
v-model="searchQuery"
26+
:autofocus="true"
2627
size="lg"
2728
:placeholder="$t('assetBrowser.searchAssetsPlaceholder')"
2829
class="max-w-96"

0 commit comments

Comments
 (0)