@@ -71,10 +71,11 @@ const history = useLocalStorage<string[]>('bc-search-history-product-landing', [
7171const localHistory = ref <InternalPostSearchResponseWithChainId [' data' ]>(history .value .map (item => JSON .parse (item )))
7272const hasHistory = computed (() => !! localHistory .value .length )
7373const hasResults = computed (() => results !== undefined )
74+ const hasInput = computed (() => searchParams .value .input .length > 0 )
7475
7576const isHistoryVisible = ref <boolean >(! hasResults .value && hasHistory .value )
7677const resultsOrHistory = computed (() => {
77- if ((! hasResults .value && hasHistory .value ) || isHistoryVisible .value ) {
78+ if ((! hasInput .value && hasHistory .value ) || isHistoryVisible .value ) {
7879 return localHistory .value
7980 }
8081 return results
@@ -83,7 +84,7 @@ const toggleHistory = () => {
8384 isHistoryVisible .value = ! isHistoryVisible .value
8485 localHistory .value = history .value .map (item => JSON .parse (item ))
8586}
86- const handleClick = (searchResult : InternalPostSearchResponseWithChainId [' data' ][number ]) => {
87+ const handleSelect = (searchResult : InternalPostSearchResponseWithChainId [' data' ][number ]) => {
8788 const currentEntry = JSON .stringify (searchResult )
8889 if (history .value .length >= 10 ) {
8990 history .value .pop ()
@@ -96,10 +97,18 @@ watch(hasResults, () => {
9697 if (hasResults .value ) return
9798 isHistoryVisible .value = true
9899})
100+ const searchInput = useTemplateRef <ComponentPublicInstance | null >(' searchInput' )
101+ const handleClickExample = (type : ' address' | ' token' | ' transaction' | ' validator' ) => {
102+ emit (' click:example' , type )
103+ isHistoryVisible .value = false
104+ const input = searchInput .value ?.$el .querySelector (' input' )
105+ input ?.focus ()
106+ }
99107 </script >
100108
101109<template >
102110 <BaseSearchInput
111+ ref =" searchInput"
103112 v-model =" searchParams.input"
104113 :is-loading =" isHistoryVisible ? false : isLoading"
105114 :has-error =" isHistoryVisible ? false : hasError"
@@ -133,7 +142,7 @@ watch(hasResults, () => {
133142 <BaseChip
134143 :is-selected =" false"
135144 icon =" stack-2"
136- @click =" emit('click:example', 'validator')"
145+ @click =" handleClickExample( 'validator')"
137146 >
138147 {{ $t('products.landing_page.search.examples.validator') }}
139148 </BaseChip >
@@ -200,7 +209,7 @@ watch(hasResults, () => {
200209 <template #result-item =" { result } " >
201210 <BlockchainSearchResultItem
202211 :result
203- @click =" handleClick (result)"
212+ @click =" handleSelect (result)"
204213 />
205214 </template >
206215
0 commit comments