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

Add possibility to cancel from onShow event #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emilpalsson
Copy link

Like tippy.js does (see code & documentation), allow the onShow callback to return false to cancel showing the tooltip.

Very useful for conditionally showing the tooltip depending on e.g. if the hovered content is currently overflown or not. I use it like this:

onShow={el => {
  const isTextOverflown = el.parentNode.offsetWidth < el.parentNode.scrollWidth
  return isTextOverflown
}}

I also added el as an argument to the callback. If you think that's a bad idea, I'll happily change.

@emilpalsson
Copy link
Author

I could also happily add the same cancellation option to onHide. Again, like tippy.js does.

@emilpalsson emilpalsson force-pushed the allow-cancellation-from-onshow branch from 60aa29d to 413b0d2 Compare June 23, 2020 18:49
@emilpalsson
Copy link
Author

I would love to hear back from you on this super small and straight forward PR. Thanks!

@atomiks
Copy link

atomiks commented Jul 2, 2020

@emilpalsson why aren't you using the official library? https://github.com/atomiks/tippyjs-react

@emilpalsson
Copy link
Author

@atomiks I wasn't aware there was one. Awesome, will definitely look into it! Thanks!

@emilpalsson
Copy link
Author

@emilpalsson why aren't you using the official library? https://github.com/atomiks/tippyjs-react

@atomiks Just wanted to tell you that we've now fully migrated to the official library and our current use case (conditionally show tooltip using the onShow prop) worked out of the box. Thanks alot!

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