Skip to content

Add possibility to cancel from onShow event#139

Open
emilpalsson wants to merge 1 commit into
tvkhoa:masterfrom
emilpalsson:allow-cancellation-from-onshow
Open

Add possibility to cancel from onShow event#139
emilpalsson wants to merge 1 commit into
tvkhoa:masterfrom
emilpalsson:allow-cancellation-from-onshow

Conversation

@emilpalsson

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Author

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

@atomiks

atomiks commented Jul 2, 2020

Copy link
Copy Markdown

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

@emilpalsson

Copy link
Copy Markdown
Author

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

@emilpalsson

Copy link
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants