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

fix: a11y fail click events have key events and no static element interactions #4169

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d5f5dca
fix: replace divs with button a11y
FatumaA Oct 5, 2024
169d2c9
fix: a11y make radio wrapper div keyboard accessible
FatumaA Oct 9, 2024
6cf18ef
fix: a11y make radio-check div keyboard accessible
FatumaA Oct 9, 2024
9d49dbb
fix: a11y prevent default of enter keys and consider spaces
FatumaA Oct 9, 2024
0829b65
fix: remove unnecessary div wrapper, add keyboard a11y to svg element
FatumaA Oct 9, 2024
4887656
fix: remove autofocus in search component
FatumaA Oct 9, 2024
2b751e1
fix: add role and keyboard behaviour to div in Search
FatumaA Oct 9, 2024
aa0a82a
fix: add keyboard behaviour in text input span
FatumaA Oct 9, 2024
e2bb063
fix: add keyboard support and correct role to toggle option
FatumaA Oct 15, 2024
816c0d9
fix: replace span with button
FatumaA Oct 15, 2024
c0979b3
fix: add keyboard support to div
FatumaA Oct 15, 2024
677fdd9
fix: prevent default on keyboard events
FatumaA Oct 15, 2024
8a670f6
fix: replace wrapper div with html button
FatumaA Oct 15, 2024
f55d9f4
fix: replace divs with html button
FatumaA Oct 15, 2024
aca76f8
fix: use html button
FatumaA Oct 15, 2024
78c8bff
fix: make div button and adjust event type
FatumaA Oct 15, 2024
d4ef29d
fix: replace p tag with anchor, replace div with button
FatumaA Oct 15, 2024
272b447
fix: replace div with button
FatumaA Oct 15, 2024
bd33e3c
fix: add keyboard support to div
FatumaA Oct 15, 2024
8089c6e
fix: replace divs with buttons
FatumaA Oct 15, 2024
ed0f477
fix: replace span with html button
FatumaA Oct 15, 2024
50c899c
fix: use button, refactor to avoid div onclick
FatumaA Oct 15, 2024
8d970d4
fix: add keyboard support to div
FatumaA Oct 15, 2024
9370c10
fix: use html buttons, add keyboard support to wrapping div
FatumaA Oct 15, 2024
925b147
fix: add descriptive title to iframe
FatumaA Oct 15, 2024
5d202c3
fix: capitalize E on "Enter"
FatumaA Oct 15, 2024
e75c9c7
fix: replace div with button in search dialog
FatumaA Oct 21, 2024
2a367c0
fix: replace div with button in dev card
FatumaA Oct 21, 2024
02a6ec6
fix: replace div with button in info card
FatumaA Oct 21, 2024
1a2863b
fix: replace div with button in dev card
FatumaA Oct 21, 2024
0aa06f8
fix: replace div with button intext input
FatumaA Oct 21, 2024
3d059f2
fix: replace div with button in card repo
FatumaA Oct 21, 2024
30c754e
fix: replace div with button in radio
FatumaA Oct 21, 2024
3a6cc65
fix: replace div with button in radio check
FatumaA Oct 21, 2024
e45f56a
fix: wrap svg in button in svg icon
FatumaA Oct 21, 2024
d8a615c
fix: replace div with button in toggle option
FatumaA Oct 21, 2024
b032f9b
fix: replace div with button in search
FatumaA Oct 21, 2024
b70442b
Update components/atoms/SVGIcon/svg-icon.tsx
FatumaA Oct 21, 2024
4bc6a8b
Update components/molecules/CardRepoList/card-repo-list.tsx
FatumaA Oct 21, 2024
9325efd
refactor: remove fragment from superlative selector
FatumaA Oct 21, 2024
13ad659
fix: remove keyboard typescript event definition
FatumaA Oct 22, 2024
839672f
fix: remove explicit type="button" in highlight input form
FatumaA Oct 22, 2024
faccd03
refactor: move button up
FatumaA Oct 22, 2024
9cf2c6b
merge beta into branch
FatumaA Oct 22, 2024
fd5f119
fix: make radio component span full width
FatumaA Oct 22, 2024
ed424c1
style: make radio check component full width
FatumaA Oct 22, 2024
a3e865e
fix: temp - revert fix of replacing div with button
FatumaA Oct 22, 2024
064563f
Merge branch 'beta' into fix-a11y-fail---click-events-have-key-events…
nickytonline Oct 22, 2024
9b72e6c
fix: use useRef to add focus the search input
FatumaA Oct 26, 2024
10e5dbd
Merge branch 'beta' into fix-a11y-fail-click-events-have-key-events-a…
FatumaA Oct 26, 2024
3a740d7
Merge branch 'beta' into fix-a11y-fail---click-events-have-key-events…
nickytonline Oct 31, 2024
d7dd6a0
chore: update .env
nickytonline Oct 31, 2024
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
6 changes: 3 additions & 3 deletions components/atoms/PillSelector/pill-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ const PillSelector: React.FC<PillSelectorProps> = ({
<PillSelectorButton>
{selected ? (
<>
<div onClick={toggleFilter}>
<button onClick={toggleFilter}>
{pillOptions.find((option) => option.toLowerCase().replaceAll(" ", "-") === selected)}
</div>
</button>
<Icon IconImage={cancelIcon} onClick={handleCancelClick} />
</>
) : (
<div onClick={toggleFilter}>Add Filter</div>
<button onClick={toggleFilter}>Add Filter</button>
)}
</PillSelectorButton>

Expand Down
8 changes: 8 additions & 0 deletions components/atoms/Radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ const Radio = ({ className, withLabel, id, children, value, checked = false, onC
return (
<div
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
onClick={onClick}
onKeyDown={(e) => {
if (onClick && (e.key === "Enter" || e.key === " ")) {
e.preventDefault();
onClick();
}
}}
tabIndex={0}
role="button"
className={
`${
checked && "!bg-light-orange-3"
Expand Down
8 changes: 8 additions & 0 deletions components/atoms/RadioCheck/radio-check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const RadioCheck = ({ className, id, children, value, checked = false, onClick }
return (
<div
onClick={onClick}
onKeyDown={(e) => {
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
if (onClick && (e.key === "Enter" || e.key === " ")) {
e.preventDefault();
onClick();
}
}}
tabIndex={0}
role="button"
className={
"px-2 py-1.5 text-sm text-black group rounded-md hover:bg-light-orange-3 hover:text-light-orange-9 hover:text-slate-800 focus:outline-none focus-visible:border-orange-500 focus-visible:ring focus-visible:ring-orange-200 transition" +
`${className}`
Expand Down
31 changes: 20 additions & 11 deletions components/atoms/SVGIcon/svg-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,26 @@ interface IconProps {

const SVGIcon: React.FC<IconProps> = ({ onClick, className, IconImage, size = 16 }) => {
return (
<div className={clsx(`inline-flex`, className)} onClick={onClick}>
<svg>
<use
href={IconImage}
width={size}
height={size}
className="items-center justify-center"
style={{ stroke: "currentcolor", maxWidth: "100%", height: "auto" }}
/>
</svg>
</div>
<svg
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
className={clsx(`inline-flex`, className)}
onClick={onClick}
onKeyDown={(e) => {
if (onClick && (e.key === "Enter" || e.key === " ")) {
e.preventDefault();
onClick();
}
}}
tabIndex={0}
role="button"
>
<use
href={IconImage}
width={size}
height={size}
className="items-center justify-center"
style={{ stroke: "currentcolor", maxWidth: "100%", height: "auto" }}
/>
</svg>
);
};

Expand Down
10 changes: 9 additions & 1 deletion components/atoms/Search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const Search = ({
<FaSearch className="text-light-slate-9" fontSize={16} onClick={handleOnSearch} />
<input
className="w-full pl-2 placeholder:text-sm focus:outline-none placeholder:text-slate-400 disabled:cursor-not-allowed"
autoFocus={autoFocus}
placeholder={placeholder}
name={name}
value={search}
Expand Down Expand Up @@ -150,10 +149,19 @@ const Search = ({
style={suggestionsStyle}
key={index}
data-suggestion={typeof suggestion === "string" ? suggestion : suggestion.key}
role="button"
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
onClick={(event) => {
const { suggestion } = (event.currentTarget as HTMLElement).dataset;
suggestion && handleOnSelect(suggestion);
}}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
const { suggestion } = (e.currentTarget as HTMLElement).dataset;
suggestion && handleOnSelect(suggestion);
}
}}
tabIndex={0}
>
{typeof suggestion === "string" ? (
<span className="pl-5 text-sm md:mw-auto inline-block text-ellipsis truncate tracking-tighter">
Expand Down
14 changes: 13 additions & 1 deletion components/atoms/TextInput/text-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ const TextInput = ({
{state === "valid" ? (
<CheckCircleFillIcon className="ml-1 text-light-orange-9" size={12} />
) : !!value ? (
<span title="Clear input" className="flex items-center ml-1" onClick={handleResetInput}>
<span
title="Clear input"
className="flex items-center ml-1"
role="button"
onClick={handleResetInput}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleResetInput();
}
}}
tabIndex={0}
>
<XCircleFillIcon
className={clsx(state === "invalid" && errorMsg ? "text-light-red-11" : "", "cursor-pointer")}
size={12}
Expand Down
9 changes: 9 additions & 0 deletions components/atoms/ToggleOption/toggle-option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ const ToggleOption = ({ optionText, withIcon, checked, handleToggle }: ToogleOpt
return (
<div
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
onClick={handleToggle}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleToggle();
}
}}
role="switch"
aria-checked={checked}
tabIndex={0}
className="inline-flex cursor-pointer items-center gap-2 rounded-md px-2 py-0.5 border border-light-slate-6 bg-light-slate-1"
>
<ToggleSwitch ariaLabel={optionText} size="sm" handleToggle={handleToggle} name={optionText} checked={checked} />
Expand Down
4 changes: 2 additions & 2 deletions components/molecules/AuthSection/auth-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const AuthSection: React.FC = ({}) => {
<FiSettings className="group-hover:text-light-orange-10" />
<Text className="group-hover:text-light-orange-10">Settings</Text>
</Link>,
<span
<button
onClick={async () => {
const pageHref = window.location.href;
const searchParams = new URLSearchParams(pageHref.substring(pageHref.indexOf("?")));
Expand All @@ -99,7 +99,7 @@ const AuthSection: React.FC = ({}) => {
>
<FiLogOut className="group-hover:text-light-orange-10" />
<Text className="group-hover:text-light-orange-10">Disconnect</Text>
</span>,
</button>,
],
};
return (
Expand Down
25 changes: 17 additions & 8 deletions components/molecules/CardRepoList/card-repo-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ const CardRepoList = ({
const sanitizedRepoList = [...new Map(repoList.map((item) => [item["repoName"], item])).values()];
const [selectedRepo, setSelectedRepo] = useState<string>("");

const handleClick = (repoOwner: any, repoName: string) => {
if (!selectedRepo) {
onSelect(`${repoOwner}/${repoName}`);
setSelectedRepo(`${repoOwner}/${repoName}`);
} else {
onSelect("");
setSelectedRepo("");
}
};
return (
<div className="flex gap-1 items-center max-w[175px] truncate flex-wrap text-xs text-light-slate-9">
{repoList.length > 0 ? (
Expand All @@ -46,15 +55,15 @@ const CardRepoList = ({
return (
<div
key={`repo_${index}`}
onClick={() => {
if (!selectedRepo) {
onSelect(`${repoOwner}/${repoName}`);
setSelectedRepo(`${repoOwner}/${repoName}`);
} else {
onSelect("");
setSelectedRepo("");
role="button"
onClick={() => handleClick(repoOwner, repoName)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleClick(repoOwner, repoName);
}
}}
tabIndex={0}
>
{repoName && repoIcon ? (
<Tooltip content={`${repoOwner}/${repoName}`}>
Expand Down Expand Up @@ -91,7 +100,7 @@ const CardRepoList = ({
)}
</div>
);
})}
})}{" "}
FatumaA marked this conversation as resolved.
Show resolved Hide resolved
<div>{repoTotal > limit ? `+${repoTotal - limit}` : null}</div>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ContributorFilterDropdown = () => {

return (
<div ref={ref} className="flex flex-col px-3 border rounded-lg shadow w-max">
<div
<button
onClick={() => setOpen((prev) => !prev)}
className="flex items-center justify-between text-sm font-normal cursor-pointer text-light-slate-9 w-44 "
>
Expand All @@ -49,7 +49,7 @@ const ContributorFilterDropdown = () => {
<BiChevronUp className="text-lg translate-y-1.5" />
<BiChevronDown className="text-lg -translate-y-1.5" />
</div>
</div>
</button>

<div
className={clsx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,25 +543,25 @@ const ContributorHighlightCard = ({
<DropdownMenuItem
className={`rounded-md ${loggedInUser?.user_metadata?.user_name === user && "hidden"}`}
>
<div
<button
onClick={isError ? follow : unFollow}
className="flex gap-2.5 py-1 items-center pl-3 pr-7 cursor-pointer"
>
<FaUserPlus size={22} />
<span>
{!isError ? "Unfollow" : "Follow"} {user}
</span>
</div>
</button>
</DropdownMenuItem>
) : (
<DropdownMenuItem className="rounded-md">
<div
<button
onClick={async () => signIn({ provider: "github" })}
className="flex gap-2.5 py-1 items-center pl-3 pr-7"
>
<FaUserPlus size={22} />
<span>Follow {user}</span>
</div>
</button>
</DropdownMenuItem>
)}
{loggedInUser && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ const ContributorListTableRow = ({
</div>
</div>
<div>
<div
<button
onClick={() => setTableOpen(!tableOpen)}
className="items-center justify-between w-6 h-6 p-1 border rounded-md "
>
{tableOpen ? <ChevronUpIcon /> : <ChevronDownIcon />}
</div>
</button>
</div>
</div>

Expand Down
10 changes: 9 additions & 1 deletion components/molecules/DevCard/dev-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function DevCard(props: DevCardProps) {
}
}, [props.isInteractive, props.isFlipped]);

function handleCardClick(event: React.MouseEvent<HTMLElement, MouseEvent>) {
function handleCardClick(event: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement>) {
if (!isInteractive) {
return;
}
Expand Down Expand Up @@ -103,7 +103,15 @@ export default function DevCard(props: DevCardProps) {
width: "245px",
height: "348px",
}}
tabIndex={0}
role="button"
onClick={handleCardClick}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleCardClick(e);
}
}}
>
<Tilt
tiltEnable={isInteractive}
Expand Down
14 changes: 7 additions & 7 deletions components/molecules/HighlightInput/highlight-input-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,14 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
}`}
/>
)}
<p
<a
className="text-light-slate-11 truncate max-w-[14rem] xs:max-w-[16rem] text-xs xs:text-sm cursor-pointer hover:text-orange-600 transition"
onClick={() => {
window.open(suggestion.url, "_blank");
}}
target="_blank"
rel="noreferrer"
href={suggestion.url}
>
{suggestion.title}
</p>
</a>
</div>
<Tooltip className="text-xs modal-tooltip" direction="top" content="Fill content">
<button
Expand Down Expand Up @@ -1024,13 +1024,13 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
)}

<Fab className="md:hidden">
<div
<button
onClick={() => setIsFormOpenMobile(true)}
className="p-3 mb-10 -mr-4 text-white rounded-full shadow-lg bg-light-orange-10"
id="mobile-highlight-create"
>
<RxPencil1 className="text-3xl" />
</div>
</button>
</Fab>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const HighlightsFilterCard = ({ repos, setSelected, selectedFilter }: Highlights
<p className="mb-2 text-sm font-normal text-light-slate-11">Click to filter the highlights</p>
<div className="flex flex-col gap-2 pt-4 border-t">
{repos.map(({ repoName, repoIcon, full_name }) => (
<div
<button
onClick={() => handleClick(full_name)}
key={full_name as string}
className={`${
Expand All @@ -30,7 +30,7 @@ const HighlightsFilterCard = ({ repos, setSelected, selectedFilter }: Highlights
>
<Icon IconImage={repoIcon} className="rounded-[4px] overflow-hidden" />
<span className="max-w-[45px] md:max-w-[100px] truncate text-xs ">{repoName}</span>
</div>
</button>
))}
</div>
</aside>
Expand Down
13 changes: 12 additions & 1 deletion components/molecules/InfoCard/info-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ export interface FavoriteRepoCardProps {

const InfoCard = ({ icon, title, description, handleClick }: FavoriteRepoCardProps): JSX.Element => {
return (
<div className="p-3 bg-white border-2 rounded-xl cursor-pointer" onClick={handleClick}>
<div
className="p-3 bg-white border-2 rounded-xl cursor-pointer"
onClick={handleClick}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleClick();
}
}}
>
<div className="flex items-center gap-2.5">
{/* Avatar */}
{icon === "github" && <FiGithub size={24} className="text-orange-200" />}
Expand Down
Loading
Loading