Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-493] chore: custom search select input key down improvement #3787

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading