Skip to content

Commit d1b693c

Browse files
committed
client(SelectInput.tsx): add a new functionality -> the filter input is active when you open the select
1 parent 56c7034 commit d1b693c

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

client/build/asset-manifest.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/build/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

client/build/static/js/main.08b3d51a.js.map renamed to client/build/static/js/main.b6f27464.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/components/input/SelectInput.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useEffect, useState } from "react";
1+
import { FC, useEffect, useRef, useState } from "react";
22
import { FiCheck } from "react-icons/fi";
33
import { useOuterClick } from "../../hooks/useOuterClick";
44

@@ -17,6 +17,7 @@ const SelectInput: FC<SelectInputProps> = (props) => {
1717
const [options, setOptions] = useState<string[]>([...props.options]);
1818

1919
const ref = useOuterClick(() => setIsActive(false));
20+
const inputRef = useRef<HTMLInputElement>(null);
2021

2122
useEffect(() => {
2223
if (filterValue.trim() === "") {
@@ -47,7 +48,12 @@ const SelectInput: FC<SelectInputProps> = (props) => {
4748
</label>
4849

4950
<div
50-
onClick={() => setIsActive((prev) => !prev)}
51+
onClick={() => {
52+
setIsActive((prev) => {
53+
if (!prev) inputRef.current?.focus();
54+
return !prev;
55+
});
56+
}}
5157
onBlur={() => setIsActive(false)}
5258
className={`ml-auto text-base border border-solid rounded-md px-2
5359
pb-1 pt-[.16rem] text-gh-text transition-all cursor-pointer
@@ -93,6 +99,7 @@ const SelectInput: FC<SelectInputProps> = (props) => {
9399
className="bg-gh-bg px-2 py-1 text-gh-text placeholder:text-gh-text-secondary
94100
border border-solid border-gh-border rounded-md outline-none
95101
focus:border-gh-blue active:border-gh-blue"
102+
ref={inputRef}
96103
/>
97104
</div>
98105
)}

0 commit comments

Comments
 (0)