From b1520783cf6b97a16fdcbbc1743eb08975241f0e Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:48:26 +0530 Subject: [PATCH] [WEB-586] chore: spreadsheet layout keyboard accessibility (#3818) * chore: spreadsheet layout peek overview close focus improvement * chore: dropdown toggle focus improvement * chore: label select toggle focus improvement * chore: comment card disabled state improvement --- web/components/dropdowns/date.tsx | 1 + web/components/dropdowns/estimate.tsx | 1 + web/components/dropdowns/module/index.tsx | 1 + web/components/dropdowns/priority.tsx | 1 + web/components/dropdowns/state.tsx | 1 + .../issue-activity/comments/comment-card.tsx | 8 +- .../issue-layouts/properties/labels.tsx | 151 +++++++++++------- .../issue-layouts/spreadsheet/issue-row.tsx | 3 +- web/components/issues/peek-overview/view.tsx | 8 +- 9 files changed, 114 insertions(+), 61 deletions(-) diff --git a/web/components/dropdowns/date.tsx b/web/components/dropdowns/date.tsx index 04c7d6948..2ba5c8af3 100644 --- a/web/components/dropdowns/date.tsx +++ b/web/components/dropdowns/date.tsx @@ -86,6 +86,7 @@ export const DateDropdown: React.FC = (props) => { const toggleDropdown = () => { if (!isOpen) onOpen(); setIsOpen((prevIsOpen) => !prevIsOpen); + if (isOpen) onClose && onClose(); }; const dropdownOnChange = (val: Date | null) => { diff --git a/web/components/dropdowns/estimate.tsx b/web/components/dropdowns/estimate.tsx index 61513cdba..663ca67ce 100644 --- a/web/components/dropdowns/estimate.tsx +++ b/web/components/dropdowns/estimate.tsx @@ -122,6 +122,7 @@ export const EstimateDropdown: React.FC = observer((props) => { const toggleDropdown = () => { if (!isOpen) onOpen(); setIsOpen((prevIsOpen) => !prevIsOpen); + if (isOpen) onClose && onClose(); }; const dropdownOnChange = (val: number | null) => { diff --git a/web/components/dropdowns/module/index.tsx b/web/components/dropdowns/module/index.tsx index ee2d746d9..5e0a3977f 100644 --- a/web/components/dropdowns/module/index.tsx +++ b/web/components/dropdowns/module/index.tsx @@ -175,6 +175,7 @@ export const ModuleDropdown: React.FC = observer((props) => { const toggleDropdown = () => { setIsOpen((prevIsOpen) => !prevIsOpen); + if (isOpen) onClose && onClose(); }; const dropdownOnChange = (val: string & string[]) => { diff --git a/web/components/dropdowns/priority.tsx b/web/components/dropdowns/priority.tsx index 3aef22233..5cacefb3f 100644 --- a/web/components/dropdowns/priority.tsx +++ b/web/components/dropdowns/priority.tsx @@ -314,6 +314,7 @@ export const PriorityDropdown: React.FC = (props) => { const toggleDropdown = () => { setIsOpen((prevIsOpen) => !prevIsOpen); + if (isOpen) onClose && onClose(); }; const dropdownOnChange = (val: TIssuePriorities) => { diff --git a/web/components/dropdowns/state.tsx b/web/components/dropdowns/state.tsx index 9591a7686..9fa2f38c8 100644 --- a/web/components/dropdowns/state.tsx +++ b/web/components/dropdowns/state.tsx @@ -104,6 +104,7 @@ export const StateDropdown: React.FC = observer((props) => { const toggleDropdown = () => { if (!isOpen) onOpen(); setIsOpen((prevIsOpen) => !prevIsOpen); + if (isOpen) onClose && onClose(); }; const dropdownOnChange = (val: string) => { diff --git a/web/components/issues/issue-detail/issue-activity/comments/comment-card.tsx b/web/components/issues/issue-detail/issue-activity/comments/comment-card.tsx index 722fd80a5..0c2c3cbb5 100644 --- a/web/components/issues/issue-detail/issue-activity/comments/comment-card.tsx +++ b/web/components/issues/issue-detail/issue-activity/comments/comment-card.tsx @@ -149,9 +149,13 @@ export const IssueCommentCard: FC = (props) => { type="button" onClick={handleSubmit(onEnter)} disabled={isSubmitting || isEmpty} - className="group rounded border border-green-500 bg-green-500/20 p-2 shadow-md duration-300 hover:bg-green-500" + className={`group rounded border border-green-500 bg-green-500/20 p-2 shadow-md duration-300 ${ + isEmpty ? "bg-gray-200 cursor-not-allowed" : "hover:bg-green-500" + }`} > - + - -
-
- - setQuery(e.target.value)} - placeholder="Search" - displayValue={(assigned: any) => assigned?.name || ""} - /> + {isOpen && ( + +
+
+ + setQuery(e.target.value)} + placeholder="Search" + displayValue={(assigned: any) => assigned?.name || ""} + onKeyDown={searchInputKeyDown} + /> +
+
+ {isLoading ? ( +

Loading...

+ ) : filteredOptions.length > 0 ? ( + filteredOptions.map((option) => ( + + `flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 hover:bg-custom-background-80 ${ + active ? "bg-custom-background-80" : "" + } ${selected ? "text-custom-text-100" : "text-custom-text-200"}` + } + > + {({ selected }) => ( + <> + {option.content} + {selected && ( +
+ +
+ )} + + )} +
+ )) + ) : ( + +

No matching results

+
+ )} +
-
- {isLoading ? ( -

Loading...

- ) : filteredOptions.length > 0 ? ( - filteredOptions.map((option) => ( - - `flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 hover:bg-custom-background-80 ${ - active ? "bg-custom-background-80" : "" - } ${selected ? "text-custom-text-100" : "text-custom-text-200"}` - } - > - {({ selected }) => ( - <> - {option.content} - {selected && ( -
- -
- )} - - )} -
- )) - ) : ( - -

No matching results

-
- )} -
-
- + + )} ); }); diff --git a/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx b/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx index 41734a867..a2935c4d7 100644 --- a/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx @@ -187,6 +187,7 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => { return ( <> {
{issueDetail.name} diff --git a/web/components/issues/peek-overview/view.tsx b/web/components/issues/peek-overview/view.tsx index 8f49a00b7..d5201bf8a 100644 --- a/web/components/issues/peek-overview/view.tsx +++ b/web/components/issues/peek-overview/view.tsx @@ -60,7 +60,13 @@ export const IssueView: FC = observer((props) => { removeRoutePeekId(); } }); - const handleKeyDown = () => !isAnyModalOpen && removeRoutePeekId(); + const handleKeyDown = () => { + if (!isAnyModalOpen) { + removeRoutePeekId(); + const issueElement = document.getElementById(`issue-${issueId}`); + if (issueElement) issueElement?.focus(); + } + }; useKeypress("Escape", handleKeyDown); return (