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

Created on 31 Jul 2020  ·  8Comments  ·  Source: facebook/docusaurus

🐛 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

bug starter good first issue help wanted mlh

Most helpful comment

https://github.com/facebook/docusaurus/pull/3240 Pull request Link.
This is my first pull request on open source community. If there's any problem, let me know.
Thanks

All 8 comments

thanks, definitively a bug to fix

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

Yes, thanks 😜

Le sam. 1 août 2020 à 18:32, Ako notifications@github.com a écrit :

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


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/docusaurus/issues/3177#issuecomment-667556206,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFW6PUPP74PRS5UP7TYQMDR6Q7QRANCNFSM4PP446NA
.

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.

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

https://github.com/facebook/docusaurus/pull/3240 Pull request Link.
This is my first pull request on open source community. If there's any problem, let me know.
Thanks

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

Problem Fixed and merged.
You can close this issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

endiliey picture endiliey  ·  3Comments

awibox picture awibox  ·  3Comments

ericnakagawa picture ericnakagawa  ·  3Comments

JoelMarcey picture JoelMarcey  ·  3Comments

philipmjohnson picture philipmjohnson  ·  3Comments