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.

Regression: Click event suddenly stopped working (Reactstrap / Popper.js 1.x)

See original GitHub issue
  • @testing-library/user-event version: 13.1.1
  • Testing Framework and version: Jest 26.6.3.
  • DOM Environment: JSDOM 16.4.0, node 12.19.0

Relevant code or config

This code opens a modal that contains some buttons and clicks on them. The modal is provided by Reactstrap (8.9.0).

    it('can discard and apply a filter selection', () => {
        render(
            <TestRootContainer initialState={mockStore}>
                <BookingsFilter />
            </TestRootContainer>,
        );

        // open filter popover
        user.click(
            screen.getByRole('button', {
                name: 'cmb-web.filter.filter-by',
            }),
        );

        // expect filter apply button
        screen.getByRole('button', { name: 'cmb-web.filter.apply' });
        // expect no filters set
        screen.getByText('cmb-ui-core.active-filter-items.no-active-filters');
        // expect no reset button
        expect(screen.queryByRole('button', { name: 'cmb-web.filter.reset' })).toBe(null);

        // select a byType filter
        user.click(screen.getByRole('button', { name: 'cmb-ui-core.account-detail-filter.credit' }));
       //^^^^^^^^^^^^^
       //Here the code execution just stops. The onclick handler on the button is never called.

        // The test failed here because the button does not appear.
        user.click(screen.getByRole('button', { name: 'cmb-web.filter.reset' }));


        // Expect popover to have closed
        expect(screen.queryByRole('button', { name: 'cmb-web.filter.apply' })).toBe(null);

What you did: This test failed after an upgrade of user-events from 12.6.3 to 13.1.1. It worked again when I downgraded back to 12.6.3.

What happened: The test failed at the marked spot. Adding async / await did not help. Also using the bound getByRole did not help.

When run with the debugger the context never switched back to the React component after the click on the button. The flow went straight to the next line in the test.

The test then failed in the next line since the button click handler had not been called the UI never updated.

Reproduction repository:

I’ll try to find time to create a minimal repo that can reproduce the issue. But I hope that maybe you have an idea what could be the reason for this regression.

Problem description: The modal component does register some event listeners on document that close it when the user clicked outside of it. Could this be the reason?

If it helps, I can go through every release in between and try to see where the regression happened.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:33 (19 by maintainers)

github_iconTop GitHub Comments

5reactions
acherkashincommented, Jun 22, 2022

If somebody still has this problem skipPointerEventsCheck option was introduced and can be used in the following way:

userEvent.click(await screen.findByText('Zoom'), {}, { skipPointerEventsCheck: true });
5reactions
vicrepcommented, Apr 9, 2021

Cool! I’ll try get something up next week 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

onClick is not working on Popper component in Material-UI ...
When interactive is not specified, Tooltip disables pointer events (so click doesn't do anything), but pointer-events is set to auto when ...
Read more >
Help with this error when trying to install dependencies : r/reactjs
Error screenshot I am getting these errors when trying to install the required dependencies. It's a theme that I downloaded from themeforest ...
Read more >
warning: kite has been deprecated because it is not ... - You.com
Kite doesn't seem to be working with jupyterlab 3.0.16 at the moment. I had the same problem for a week and then I...
Read more >
Reactstrap: A Simple React Bootstrap 4 Components - Morioh
In this library, we will learn about Reactstrap: A Simple React Bootstrap 4 Components Stateless React Components for Bootstrap 5.
Read more >
Event Listeners - Popper
Event Listeners. The eventListeners modifier adds scroll and resize listeners that update the position of the popper when necessary. These are not ......
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