mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: enter to select first tank
This commit is contained in:
1 parent
6d48f9fe7f
commit
2e0d52e30e
1 file changed
+25
@@ -1,6 +1,7 @@
|
|||||||
import { slateDark } from '@radix-ui/colors';
|
import { slateDark } from '@radix-ui/colors';
|
||||||
import {
|
import {
|
||||||
CaretDownIcon,
|
CaretDownIcon,
|
||||||
|
CaretRightIcon,
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
@@ -445,10 +446,34 @@ export function TankSearch({
|
|||||||
|
|
||||||
setSearchedList(results);
|
setSearchedList(results);
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
if (
|
||||||
|
searchResults.length > 0 &&
|
||||||
|
input.current &&
|
||||||
|
input.current.value.length > 0
|
||||||
|
) {
|
||||||
|
onSelect(searchResults[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<TextField.Slot>
|
<TextField.Slot>
|
||||||
<MagnifyingGlassIcon height="16" width="16" />
|
<MagnifyingGlassIcon height="16" width="16" />
|
||||||
</TextField.Slot>
|
</TextField.Slot>
|
||||||
|
|
||||||
|
{searchResults.length > 0 &&
|
||||||
|
input.current &&
|
||||||
|
input.current.value.length > 0 && (
|
||||||
|
<TextField.Slot>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => onSelect(searchResults[0])}
|
||||||
|
>
|
||||||
|
{searchResults[0].name} <CaretRightIcon />
|
||||||
|
</Button>
|
||||||
|
</TextField.Slot>
|
||||||
|
)}
|
||||||
</TextField.Root>
|
</TextField.Root>
|
||||||
|
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
|
|||||||
Reference in new issue
Block a user