Skip to content

spotlightClicks fails for targets within scrollable containers on @next branch #1167

@yuvalkarmi

Description

@yuvalkarmi

Hey @gilbarbara,

First off, huge thanks for creating and maintaining react-joyride - it's an incredibly useful library!

I wanted to report a potential issue I ran into while using the next branch (^3.0.0-7).

🐛 Bug Report

On the @next branch (^3.0.0-7), when using spotlightClicks: true for a step targeting an element inside a scrollable container (e.g., div with overflow-y: auto), clicks on the highlighted target element are blocked by the overlay. (I tested this with disableOverlayClose={true} is set on the <Joyride> component). The click does not propagate to the underlying target element.

To Reproduce

Steps to reproduce the behavior:

  1. Open the CodeSandbox demo linked below (uses react-joyride@^3.0.0-7).
  2. Click the "Start Tour" button.
  3. Scroll inside the light blue bordered box (the scrollable container) down until the red "Click Me (Target)" button is clearly visible within the spotlight.
  4. Try clicking directly on the red "Click Me (Target)" button.

Actual behavior

The click appears to be intercepted by the Joyride overlay. The red target button's onClick handler is not triggered, and the expected alert does not appear.

Expected behavior

The click should register on the target button because spotlightClicks: true is enabled for the step. The button's onClick handler should fire (triggering an alert in the demo).

Link to Codesandbox

https://codesandbox.io/p/sandbox/9lmqzq

Possible Cause (My best guess)

Digging through the code (specifically around the handleMouseMove logic in v3), it looks like the calculation to determine if the user's mouse cursor is currently over the spotlighted target element might be incorrect when that element is inside a scrolled container. The coordinates being compared (mouse position vs. target bounds) might not align correctly after the intermediate container scrolls. useMemo on spotlightStyles in Overlay.tsx in causes an issue:
spotlightStyles was previously calculated in realtime in 2.7.2, but that's no longer the case with useMemo. As a consequence, the overlay's pointer-events style isn't correctly switched to none when hovering over the target, thus blocking the click.

Additional Context

  • This behavior seems specific to the next/v3 branch. If you take the exact same CodeSandbox and change the react-joyride dependency back to 2.7.2, the spotlightClicks feature works correctly in the scrollable container. This strongly suggests a change between v2.7.2 and the next branch related to event handling or coordinate calculation within scrolled containers.
  • On a personal note, I can't downgrade to v2 because I use React 19

Thanks again for your work on this library! Let me know if any more information would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions