Skip to content

Commit

Permalink
chore: custom search select input key down improvement (#3787)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolsinghbhatia authored Feb 26, 2024
1 parent 888268a commit 67fdafb
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web/components/dropdowns/cycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ export const CycleDropdown: React.FC<Props> = observer((props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

useEffect(() => {
Expand Down Expand Up @@ -231,6 +238,7 @@ export const CycleDropdown: React.FC<Props> = observer((props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
8 changes: 8 additions & 0 deletions web/components/dropdowns/estimate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

useEffect(() => {
Expand Down Expand Up @@ -217,6 +224,7 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
8 changes: 8 additions & 0 deletions web/components/dropdowns/member/project-member.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ export const ProjectMemberDropdown: React.FC<Props> = observer((props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

useEffect(() => {
Expand Down Expand Up @@ -215,6 +222,7 @@ export const ProjectMemberDropdown: React.FC<Props> = observer((props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
8 changes: 8 additions & 0 deletions web/components/dropdowns/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

const comboboxProps: any = {
Expand Down Expand Up @@ -349,6 +356,7 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
8 changes: 8 additions & 0 deletions web/components/dropdowns/priority.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

const ButtonToRender = BORDER_BUTTON_VARIANTS.includes(buttonVariant)
Expand Down Expand Up @@ -417,6 +424,7 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
8 changes: 8 additions & 0 deletions web/components/dropdowns/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
toggleDropdown();
};

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

useOutsideClickDetector(dropdownRef, handleClose);

useEffect(() => {
Expand Down Expand Up @@ -205,6 +212,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ export const IssueLabelSelect: React.FC<IIssueLabelSelect> = observer((props) =>
</div>
);

const searchInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (query !== "" && e.key === "Escape") {
e.stopPropagation();
setQuery("");
}
};

if (!issue) return <></>;

return (
Expand Down Expand Up @@ -118,6 +125,7 @@ export const IssueLabelSelect: React.FC<IIssueLabelSelect> = observer((props) =>
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
onKeyDown={searchInputKeyDown}
/>
</div>
</div>
Expand Down

0 comments on commit 67fdafb

Please sign in to comment.