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 51 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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ NEXT_PUBLIC_API_URL=https://beta.api.opensauced.pizza/v2
NEXT_PUBLIC_EXP_API_URL=https://beta.api.opensauced.pizza/v2
NEXT_PUBLIC_POSTHOG_ID=phc_Y0xz6nK55MEwWjobJsI2P8rsiomZJ6eZLoXehmMy9tt
NEXT_PUBLIC_CLOUD_NAME=dgxgziswe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=test
NEXT_PUBLIC_STRIPE_SUB_CANCEL_URL=https://billing.stripe.com/p/login/test_bIY8xy3iy6fpeHu3cc
nickytonline marked this conversation as resolved.
Show resolved Hide resolved
SENTRY_DSN=https://3f5bb9023ff0407299dd22a6454558f9@o4504872488927232.ingest.sentry.io/4505082236960768
NEXT_PUBLIC_SENTRY_DSN=https://3f5bb9023ff0407299dd22a6454558f9@o4504872488927232.ingest.sentry.io/4505082236960768

Expand Down
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
6 changes: 3 additions & 3 deletions components/atoms/Radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ interface RadioProps {

const Radio = ({ className, withLabel, id, children, value, checked = false, onClick }: RadioProps): JSX.Element => {
return (
<div
<button
onClick={onClick}
className={
`${
checked && "!bg-light-orange-3"
} px-2 py-1.5 text-sm text-slate-600 group rounded-md hover:bg-light-orange-3 hover:text-slate-800 focus:outline-none focus-visible:border-orange-500 focus-visible:ring focus-visible:ring-orange-200 transition` +
} w-full px-2 py-1.5 text-sm text-slate-600 group rounded-md hover:bg-light-orange-3 hover:text-slate-800 focus:outline-none focus-visible:border-orange-500 focus-visible:ring focus-visible:ring-orange-200 transition` +
`${className}`
}
>
Expand Down Expand Up @@ -49,7 +49,7 @@ const Radio = ({ className, withLabel, id, children, value, checked = false, onC
</span>
)}
</label>
</div>
</button>
);
};

Expand Down
6 changes: 3 additions & 3 deletions components/atoms/RadioCheck/radio-check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ interface RadioCheckProps {

const RadioCheck = ({ className, id, children, value, checked = false, onClick }: RadioCheckProps): JSX.Element => {
return (
<div
<button
onClick={onClick}
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" +
"w-full 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 All @@ -36,7 +36,7 @@ const RadioCheck = ({ className, id, children, value, checked = false, onClick }
)}
<span className="ml-3 leading-none my-auto">{children}</span>
</label>
</div>
</button>
);
};

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/SVGIcon/svg-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IconProps {

const SVGIcon: React.FC<IconProps> = ({ onClick, className, IconImage, size = 16 }) => {
return (
<div className={clsx(`inline-flex`, className)} onClick={onClick}>
<button className={clsx(`inline-flex`, className)} onClick={onClick}>
<svg>
<use
href={IconImage}
Expand All @@ -21,7 +21,7 @@ const SVGIcon: React.FC<IconProps> = ({ onClick, className, IconImage, size = 16
style={{ stroke: "currentcolor", maxWidth: "100%", height: "auto" }}
/>
</svg>
</div>
</button>
);
};

Expand Down
5 changes: 2 additions & 3 deletions 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 All @@ -141,7 +140,7 @@ const Search = ({
<ScrollArea type="auto" className="h-60">
{suggestionsLabel && suggestions.length > 0 ? <div className="pl-5 pt-4">{suggestionsLabel}</div> : null}
{suggestions.map((suggestion, index) => (
<div
<button
className={clsx(
cursor === index && "_cursorActive bg-slate-100",
"px-4 py-2 hover:bg-light-slate-2",
Expand All @@ -162,7 +161,7 @@ const Search = ({
) : (
suggestion.node
)}
</div>
</button>
))}
</ScrollArea>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/TextInput/text-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ 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}>
<button title="Clear input" className="flex items-center ml-1" onClick={handleResetInput}>
<XCircleFillIcon
className={clsx(state === "invalid" && errorMsg ? "text-light-red-11" : "", "cursor-pointer")}
size={12}
/>
</span>
</button>
) : (
""
)}
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/ToggleOption/toggle-option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface ToogleOptionProps {
}
const ToggleOption = ({ optionText, withIcon, checked, handleToggle }: ToogleOptionProps): JSX.Element => {
return (
<div
<button
onClick={handleToggle}
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"
>
Expand All @@ -20,7 +20,7 @@ const ToggleOption = ({ optionText, withIcon, checked, handleToggle }: ToogleOpt
className="text-light-slate-9"
/>
)}
</div>
</button>
);
};
export default ToggleOption;
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
24 changes: 11 additions & 13 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 @@ -44,18 +53,7 @@ const CardRepoList = ({
.filter((_, arrCount) => arrCount < limit)
.map(({ repoOwner, repoName, repoIcon }, index) => {
return (
<div
key={`repo_${index}`}
onClick={() => {
if (!selectedRepo) {
onSelect(`${repoOwner}/${repoName}`);
setSelectedRepo(`${repoOwner}/${repoName}`);
} else {
onSelect("");
setSelectedRepo("");
}
}}
>
<button key={`repo_${index}`} onClick={() => handleClick(repoOwner, repoName)}>
{repoName && repoIcon ? (
<Tooltip content={`${repoOwner}/${repoName}`}>
<div
Expand Down Expand Up @@ -89,7 +87,7 @@ const CardRepoList = ({
) : (
""
)}
</div>
</button>
);
})}
<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
4 changes: 2 additions & 2 deletions components/molecules/DevCard/dev-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function DevCard(props: DevCardProps) {
<div style={{ ...faceStyle }} className="DevCard-card relative rounded-xl w-full h-full border border-gray-400" />
</animated.div>
) : (
<div
<button
className="DevCard select-none"
style={{
width: "245px",
Expand Down Expand Up @@ -238,7 +238,7 @@ export default function DevCard(props: DevCardProps) {
</div>
</div>
</Tilt>
</div>
</button>
);
}

Expand Down
16 changes: 9 additions & 7 deletions components/molecules/HighlightInput/highlight-input-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,10 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
/>
)}
<a
href={suggestion.url}
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"
target="_blank"
className="truncate max-w-[14rem] xs:max-w-[16rem] text-xs xs:text-sm"
rel="noreferrer"
href={suggestion.url}
>
{suggestion.title}
</a>
Expand Down Expand Up @@ -846,7 +847,7 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
className="fixed left-0 right-0 z-30 h-screen py-4 transition bg-white top-24 md:hidden"
>
<div className="flex items-center justify-between w-full px-2">
<button onClick={() => setIsFormOpenMobile(false)} type="button">
<button onClick={() => setIsFormOpenMobile(false)}>
<IoClose className="text-2xl text-light-slate-10" />
</button>
<Button
Expand Down Expand Up @@ -1022,14 +1023,15 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
</form>
)}

<Fab className="md:hidden" onClick={() => setIsFormOpenMobile(true)}>
<span
className="outline-none p-3 mb-10 -mr-4 text-white rounded-full shadow-lg bg-light-orange-10"
<Fab className="md:hidden">
<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"
>
<span className="sr-only">Create a highlight</span>
<RxPencil1 className="text-3xl" />
</span>
</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
4 changes: 2 additions & 2 deletions components/molecules/InfoCard/info-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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}>
<button className="p-3 bg-white border-2 rounded-xl cursor-pointer" onClick={handleClick}>
<div className="flex items-center gap-2.5">
{/* Avatar */}
{icon === "github" && <FiGithub size={24} className="text-orange-200" />}
Expand All @@ -21,7 +21,7 @@ const InfoCard = ({ icon, title, description, handleClick }: FavoriteRepoCardPro
<div className="text-sm text-gray-400 tracking-tight -mt-0.5">{description}</div>
</div>
</div>
</div>
</button>
);
};

Expand Down
8 changes: 4 additions & 4 deletions components/molecules/RepoRow/repo-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ const RepoRow = ({ repo, topic, userPage, selected, handleOnSelectRepo }: RepoPr
)}
</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 Expand Up @@ -225,9 +225,9 @@ const RepoRow = ({ repo, topic, userPage, selected, handleOnSelectRepo }: RepoPr
</div>
</div>

<div onClick={() => setTableOpen(!tableOpen)} className="py-1 mt-3 text-center border rounded-lg">
<button onClick={() => setTableOpen(!tableOpen)} className="py-1 mt-3 text-center border rounded-lg">
Hide details
</div>
</button>
</div>
</div>
<div className={`${classNames.row} `}>
Expand Down
Loading
Loading