Why is it not effective to bind the click event on the 'react-joyride__spotlight' dom? #1096
-
Hello! Thank you very much for providing such an excellent npm package. I am trying to package this npm package into a business SDK that can be used across different websites within the company without modifying the code for each individual site. I am currently encountering some usage issues and would like to seek assistance. I hope to be able to control the behavior of the element with
1 can succeed, but 2 does not. Here is my implementation code for 2。
and I also set pointer-events auto
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @xyyit9 When you move your cursor over the spotlight, the overlay changes its So add the And then: if (portal) {
portal.style.cursor = 'pointer'; // This won't work since the overlay gets the cursor event, so it's using its styles.
portal.addEventListener('click', function () {
console.log('portal click!');
});
} The library never knows what content it interacts with; it just renders stuff on top of it. So, you are on your own to handle everything,
|
Beta Was this translation helpful? Give feedback.
Hey @xyyit9
When you move your cursor over the spotlight, the overlay changes its
pointer-events
to none, so the click goes through, and the element behind the spotlight receives it "without interference".Changing the overlay
pointer-events
to auto triggers its close listener.If not using the
disableOverlayClose: true
prop, the event never reaches the portal.So add the
disableOverlayClose
prop on your step(s).Also, ensure the only style change is:
.react-joyride__overlay { cursor: pointer !important; pointer-events: auto !important; }
.And then: