Skip to content
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

fix(src/index.js): Overwrite delayHide on scroll #504

Merged
merged 1 commit into from
Sep 6, 2019
Merged

fix(src/index.js): Overwrite delayHide on scroll #504

merged 1 commit into from
Sep 6, 2019

Conversation

tihuan
Copy link
Contributor

@tihuan tihuan commented Jul 23, 2019

Add new param options to hideTooltip() and update addScrollListener()
to set options to { isScroll: true }, so hideTooltip() can set
delayHide to 0 if isScroll is true

fix #474

@tihuan
Copy link
Contributor Author

tihuan commented Jul 31, 2019

@aronhelser gentle ping 🙏 Thank you!

src/index.js Outdated

const hideTooltip = (event, hasTarget) => this.hideTooltip(event, hasTarget, { isScroll: true })

window.addEventListener('scroll', hideTooltip, isCaptureMode)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function added here no longer matches this.hideTooltip inside removeScrollListener, and I think that's a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aronhelser! Thanks so much for taking the time to check the PR 🙏

Ahh I see, so since window.addEventListener('scroll', hideTooltip, isCaptureMode) refers to a different function from this.hideTooltip, window.removeEventListener('scroll', this.hideTooltip) won't be able to clear const hideTooltip, and thus introducing memory leak.

Will need to think about a way around this 👍

Thanks for catching that!

Add new param `options` to `hideTooltip()` and update `addScrollListener()`
to set `options` to `{ isScroll: true }`, so `hideTooltip()` can set
`delayHide` to `0` if `isScroll` is `true`

fix #474
@tihuan
Copy link
Contributor Author

tihuan commented Sep 5, 2019

Hi @aronhelser! I just updated the PR to use a new method hideTooltipOnScroll(), which calls hideTooltip with { isScroll: true }. This should resolve the memory leak issue above.

gif

PTAL again 🙏 Thank you!

@aronhelser
Copy link
Collaborator

Awesome, thanks!

@aronhelser aronhelser merged commit 11ee685 into ReactTooltip:master Sep 6, 2019
@wwayne
Copy link
Collaborator

wwayne commented Sep 6, 2019

🎉 This PR is included in version 3.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tihuan tihuan deleted the fix-474 branch September 6, 2019 16:00
@tihuan
Copy link
Contributor Author

tihuan commented Sep 6, 2019

Hurray! Thanks again for the great review, @aronhelser ! Have an amazing weekend!

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.

delayHide create confusion when hidding tooltip due to a scroll event
3 participants