Skip to content

Commit e87be49

Browse files
committed
feat: enhance accessibility in SearcherBar component; add ARIA roles and attributes to input and error messages
1 parent 6693077 commit e87be49

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/modules/search/SearcherBar.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ export function SearcherBar({
154154
onChange={(e) => setInputValue(e.target.value)}
155155
onKeyDown={handleKeyDown}
156156
disabled={isPending}
157+
type="search"
158+
role="searchbox"
159+
aria-label="Search for addresses, deal IDs, task IDs, or transaction hashes"
160+
aria-describedby={localError || error ? 'search-error' : undefined}
157161
className={cn(
158162
'bg-muted border-secondary w-full rounded-2xl py-5.5 pl-12 sm:py-6.5',
159163
isConnected && 'sm:pr-32',
@@ -164,7 +168,12 @@ export function SearcherBar({
164168
placeholder="Search address, deal id, task id, transaction hash..."
165169
/>
166170
{(localError || error) && (
167-
<p className="bg-danger text-danger-foreground border-danger-border absolute -bottom-8 rounded-full border px-4">
171+
<p
172+
id="search-error"
173+
role="alert"
174+
aria-live="polite"
175+
className="bg-danger text-danger-foreground border-danger-border absolute -bottom-8 rounded-full border px-4"
176+
>
168177
{localError ? localError.message : error?.message}
169178
</p>
170179
)}
@@ -175,8 +184,19 @@ export function SearcherBar({
175184
</div>
176185

177186
<div className={cn('mt-4 flex justify-center gap-4', isError && 'mt-10')}>
178-
<div className="flex justify-center sm:hidden">
179-
<Button variant="outline" onClick={handleSearch} disabled={isPending}>
187+
<div className="flex justify-center sm:sr-only">
188+
<Button
189+
variant="outline"
190+
onClick={handleSearch}
191+
disabled={isPending}
192+
type="button"
193+
aria-label={
194+
isPending
195+
? 'Searching in progress'
196+
: 'Search for the entered value'
197+
}
198+
tabIndex={0}
199+
>
180200
{isPending ? 'Searching...' : 'Search'}
181201
</Button>
182202
</div>

0 commit comments

Comments
 (0)