focus input on first click (#34283)

fixes: #34054

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-10-25 15:26:44 +02:00 committed by GitHub
parent 4d25128018
commit b57b0bec88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -160,7 +160,6 @@ export const TypeaheadSelectControl = <
render={({ field }) => (
<Select
{...rest}
onClick={() => setOpen(!open)}
onOpenChange={() => setOpen(false)}
selected={
isSelectBasedOptions(options)
@ -173,12 +172,16 @@ export const TypeaheadSelectControl = <
.map((o) => o.value)
: field.value
}
shouldFocusFirstItemOnOpen={false}
toggle={(ref) => (
<MenuToggle
ref={ref}
id={id || name.slice(name.lastIndexOf(".") + 1)}
variant="typeahead"
onClick={() => setOpen(!open)}
onClick={() => {
setOpen(!open);
textInputRef.current?.focus();
}}
isExpanded={open}
isFullWidth
status={get(errors, name) ? MenuToggleStatus.danger : undefined}