Skip to content

Fix: Resolve spotlight flickering issue on elements with spotlightClicks enabled #1153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

maoryadin
Copy link

Description:
This PR refactors the hideSpotlight method to resolve a flickering issue when interacting with elements with spotlightClicks enabled.

Key Changes:
• Optimized hideSpotlight logic:
Simplified and memoized the hidden lifecycle conditions by moving hiddenLifecycles to a constant outside the method.
• Bug Fix:
Previously, the spotlight would briefly flicker when clicking elements with spotlightClicks enabled due to unnecessary re-evaluations of the overlay condition. The updated logic ensures consistent behavior by streamlining the condition check.

Refactor `hideSpotlight` function in `src/components/Overlay.tsx`.

* Remove `continuous` from the destructured props.
* Define `hiddenLifecycles` array with `LIFECYCLE.BEACON`, `LIFECYCLE.COMPLETE`, and `LIFECYCLE.ERROR`.
* Return true if `disableOverlay` is true or if `lifecycle` is in `hiddenLifecycles` array.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/maoryadin/react-joyride?shareId=XXXX-XXXX-XXXX-XXXX).
Copy link

codesandbox bot commented Mar 24, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

codesandbox-ci bot commented Mar 24, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@maoryadin maoryadin closed this Mar 25, 2025
@maoryadin maoryadin reopened this Mar 25, 2025
Update `hideSpotlight` function and `componentWillUnmount` method in `src/components/Overlay.tsx`.

* Add `continuous` to the destructured props in the `hideSpotlight` function.
* Update the `hiddenLifecycles` array to include `LIFECYCLE.BEACON`, `LIFECYCLE.COMPLETE`, and `LIFECYCLE.ERROR`.
* Update the `shouldHide` variable to account for the `continuous` property.
* Update the `hideSpotlight` function to return `shouldHide`.
* Add state reset for `mouseOverSpotlight` to `componentWillUnmount` method.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/maoryadin/react-joyride?shareId=XXXX-XXXX-XXXX-XXXX).
Fix overlay spotlight hiding logic
…lifecycle changes in componentDidUpdate

Refactor `componentDidUpdate` method in `src/components/Overlay.tsx` to handle `spotlightClicks`, `disableOverlay`, and `lifecycle` changes.

* Add logic to remove `mousemove` event listener and reset `mouseOverSpotlight` state when `spotlightClicks` or `lifecycle` changes.
* Add logic to add `mousemove` event listener when `spotlightClicks` is true and `lifecycle` is `LIFECYCLE.TOOLTIP`.
* Remove redundant `mousemove` event listener removal logic.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/maoryadin/react-joyride?shareId=XXXX-XXXX-XXXX-XXXX).
Fix overlay component to handle spotlightClicks, disableOverlay, and lifecycle changes in componentDidUpdate
@gilbarbara
Copy link
Owner

Hey @maoryadin

Did you try the pre-release version?

npm i react-joyride@next

Do you still have the problem with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants