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

After opening the dropdown menu from nav with keyboard, it doesn't collapse back if I click anywhere else by mouse. #3177

Closed
mdfaizan7 opened this issue Jul 31, 2020 · 8 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship

Comments

@mdfaizan7
Copy link
Contributor

mdfaizan7 commented Jul 31, 2020

🐛 Bug Report

After opening the dropdown menu from nav with keyboard, it doesn't collapse back if I click on anywhere else by mouse

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Use the Tab key to open the dropdown menu on the nav.
  2. Click on the screen outside the menu.

Expected behavior

When mouse key is pressed outside the dropdown menu, the menu should have collapsed.

Actual Behavior

The dropdown menu did not collapse and stayed opened. Even if I again clicked the menu with my mouse, it did not collapse.

Your Environment

  • The bug shows up on both https://v2.docusaurus.io/docs and a locally installed Docusaurus v2
  • Laptop Windows 10
  • This issue was reproducible on both Firefox and Chrome.

Reproducible Demo

You can see this bug in the documentation itself.

2020-07-31 14-40-13

@mdfaizan7 mdfaizan7 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 31, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 31, 2020

thanks, definitively a bug to fix

@slorber slorber added difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship and removed status: needs triage This issue has not been triaged by maintainers labels Jul 31, 2020
@Ako92
Copy link
Contributor

Ako92 commented Aug 1, 2020

I want to Handle this problem. can you assign it to me?

@slorber
Copy link
Collaborator

slorber commented Aug 1, 2020 via email

@Ako92
Copy link
Contributor

Ako92 commented Aug 7, 2020

I'm working on it.
What is the expected behavior? There is two options:

  1. Remove the tab key press functionality on DropDown
  2. Add eventListener on window to toggle className "dropdown--show" if exists!

If you have any other solution please share it with me.

@slorber
Copy link
Collaborator

slorber commented Aug 7, 2020

Thanks for working on this.

I'm not very comfortable with the current code that mutates the dom directly. Would be cool to refactor this and add some proper React state.

We should be able to use the dropdown without a mouse for accessibility, so the 2nd solution looks better to me. I've used such libs successfully in the past: https://github.com/Andarist/use-onclickoutside

@Ako92
Copy link
Contributor

Ako92 commented Aug 7, 2020

#3240 Pull request Link.
This is my first pull request on open source community. If there's any problem, let me know.
Thanks

@mdfaizan7
Copy link
Contributor Author

Thank You for the pull request @Ako92. It looks like this bug is fixed. Good Job 👍

@Ako92
Copy link
Contributor

Ako92 commented Aug 13, 2020

Problem Fixed and merged.
You can close this issue!

@slorber slorber closed this as completed Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship
Projects
None yet
Development

No branches or pull requests

3 participants