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