From 8b2ffa141e2fe35f4b36ac5593ab9de8f819fac6 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 7 Feb 2025 09:38:18 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=20a11y:=20MultiSearch=20Clear=20In?= =?UTF-8?q?put=20(#5718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add accessibility features to model search * chore: linting * fix: Improve accessibility by adding aria-label to MultiSearch input * refactor: MultiSearch component as button * refactor: Update MultiSearch component styles for improved theming * refactor: Update MultiSearch component styles for improved visual consistency --------- Co-authored-by: Derek Jackson Co-authored-by: derek jackson <63861027+derekjackson-das@users.noreply.github.com> Co-authored-by: Ruben Talstra --- client/src/components/ui/MultiSearch.tsx | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/client/src/components/ui/MultiSearch.tsx b/client/src/components/ui/MultiSearch.tsx index 8dda8cc8c9..64767c6442 100644 --- a/client/src/components/ui/MultiSearch.tsx +++ b/client/src/components/ui/MultiSearch.tsx @@ -1,10 +1,9 @@ import { Search, X } from 'lucide-react'; -import React, { useState, useMemo, useCallback } from 'react'; +import React, { useState, useMemo, useCallback, useRef } from 'react'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; -// This is a generic that can be added to Menu and Select components - +/** This is a generic that can be added to Menu and Select components */ export default function MultiSearch({ value, onChange, @@ -17,35 +16,57 @@ export default function MultiSearch({ className?: string; }) { const localize = useLocalize(); + const inputRef = useRef(null); + const onChangeHandler: React.ChangeEventHandler = useCallback( (e) => onChange(e.target.value), [onChange], ); + const clearSearch = () => { + onChange(''); + setTimeout(() => { + inputRef.current?.focus(); + }, 0); + }; + return (
- + -
+
+
); }