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

polish: bind key listener to light/dark toggle + a11y lint fixes #5341

Merged
merged 6 commits into from
Aug 12, 2021

Conversation

Josh-Cena
Copy link
Collaborator

Motivation

Fix more ESLint warnings about a11y. Toggle deserves to have a key listener, so let's give it one (although not at the place ESLint suggests)

Have you read the Contributing Guidelines on pull requests?

Yea

Test Plan

On the main page, use tab to focus the Toggle, and press enter to see the theme toggled.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 11, 2021
@netlify
Copy link

netlify bot commented Aug 11, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 6a9bde8

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6115243bde91b90008aecc7f

😎 Browse the preview: https://deploy-preview-5341--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Aug 11, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 87
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5341--docusaurus-2.netlify.app/

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
@@ -39,6 +39,23 @@ const Details = ({summary, children, ...props}: DetailsProps): JSX.Element => {
// We use a separate prop because it must be set only after animation completes
// Otherwise close anim won't work
const [open, setOpen] = useState(props.open);
const toggle = (e: React.SyntheticEvent) => {
Copy link
Collaborator

@slorber slorber Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I'd rather not extract this method, it's only used in one place and it's not even meant to be reusable considering it's handling a click dom event. Extracting the code and naming it "toggle" makes this more implicit and imply a reusable api. If you really want to extract this (like for perf reasons using useCallback which in this case wouldn't improve anything), you'd rather name it handleClick.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I wrote this a week ago and no idea why I extracted it back then 🤦‍♂️

@slorber
Copy link
Collaborator

slorber commented Aug 12, 2021

👍

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
@slorber slorber added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Aug 12, 2021
@slorber slorber merged commit 69b11a8 into facebook:master Aug 12, 2021
@Josh-Cena Josh-Cena deleted the a11y branch August 12, 2021 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants