question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[menu-button] Cannot immediately click menu item in tests - 0.16.0 regression

See original GitHub issue

🐛 Bug report

Current Behavior

After updating @reach/menu-button to 0.16.1 in my app, a few tests started to fail. The menus still seem to work okay in manual testing, but I think it’s because the tests are running faster than a human can click things.

I’ve found that I need to make two clicks to a menu item for it to take effect, or add about a half-second delay after opening the menu before clicking the item.

Expected behavior

Menu items should be possible to click as soon as the menu opens.

Reproducible example

https://codesandbox.io/s/reach-menu-button-0-16-cant-click-menuitem-in-test-v93z3?file=/src/__tests__/App.test.js

Note that the test fails, but uncommenting out the delay or the second click should cause the test to pass. If not, try refreshing the browser window, I’ve found that codesandbox tests can be kind of flakey.

Also, if you change the version of @reach/menu-button to 0.15.3, and reload the page, the test should start to pass without the delay or double-click.

Suggested solution(s)

I think maybe something changed so that the menu items aren’t ready for clicks right away?

Additional context

Your environment

Software Name(s) Version
Reach Package menu-button 0.16.0
React 17.0.3
Browser n/a
Assistive tech n/a
Node n/a
npm/yarn npm
Operating System mac

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
IanVScommented, Sep 20, 2021

@chaance is this indeed working as intended? I think it’s pretty confusing behavior when writing tests, and it took me a while just to figure out why my tests were failing. It seems that this could be mentioned in the changelog, or even the docs site, as a testing tip until/unless some kind of heuristics can be used to determine whether or not the component is running in a testing environment.

1reaction
stephenwadecommented, Sep 9, 2021

Seems to be intentional behavior. It was changed in https://github.com/reach/reach-ui/commit/4e7fc922307ccf24f76b5b54d75af8d046fd29da.

For more information, see the discussion in https://github.com/reach/reach-ui/issues/563.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not click on menu unless it has menu item - Stack Overflow
Implementing it to fire in that context is possible (beware: it ... is an item in a ContextMenu and not when represented by...
Read more >
GParted -- All News
This release of GParted Live has been successfully tested on VirtualBox, VMware, BIOS, UEFI, and physical computers with AMD/ATI, NVidia, and Intel graphics....
Read more >
@reach/menu-button | Yarn - Package Manager
An accessible dropdown menu for the common dropdown menu button design pattern. import { Menu, MenuList, MenuButton, MenuItem, MenuLink, } from "@reach/menu- ......
Read more >
Navigation Menu Button | ARIA-AT Reports
Test Name, Required Assertions, Optional Assertions, Unexpected Behaviors. Navigate forwards to a menu button in reading mode, 8 of 8 passed, None, None....
Read more >
Simulating Menu Actions | TestComplete Documentation
To work with menus in tests, use the Menu object. ... menus must be displayed on screen first since TestComplete cannot invoke context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found