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

[BUG] : When ' (single quote) is used any where in the text, the tooltip doesn't open #1175

Closed
parthee11 opened this issue Mar 4, 2024 · 4 comments · Fixed by #1187
Closed
Labels

Comments

@parthee11
Copy link

Bug description
When ' (single quote) is used any where in the text, the tooltip doesn't open.

Version of Package
v5.21.5

To Reproduce

  • Make sure there is at least one ' added to the content you passing, eg: Animal's Park to reproduce the issue

Expected behavior

  • This should work similar to other text content

Screenshots

  • Where we have the text Hgjvkwlq;'Dlk.. and Erfdgbqqwerfgjghvkjk'ljhgfchijhgfhchjjilghcjgchvh, the tooltip is not open
image
@parthee11 parthee11 added the Bug label Mar 4, 2024
@gabrieljablonski
Copy link
Member

Cannot reproduce this neither on v5.21.5 nor on v5.26.3 (latest version as of writing this).

https://stackblitz.com/edit/vitejs-vite-jblnec?file=src%2FApp.tsx&terminal=dev

What's most likely happening is that you're using the content as the id for the tooltip, which is not allowed on the HTML id attribute. Look at the console and you should see a warning message prefixed with [react-tooltip]. See #1150 for more details.

If that's the case, you should consider not using a tooltip for each one of your items. See the Dynamically generated anchor elements section on the docs for why you shouldn't do it.

Please confirm if it's indeed an issue with the id, and we will also add this to the troubleshooting page.

@parthee11
Copy link
Author

Sure @gabrieljablonski , what you have explained makes sense. Will check once

@gabrieljablonski
Copy link
Member

gabrieljablonski commented Mar 16, 2024

Although you should still update your application to use less tooltip elements, as suggested above, there is indeed a bug regarding using ' in the id (which is allowed according to MDN docs, only whitespace characters are not allowed).

This is due to how we build the CSS selector string:

document.querySelectorAll(`[data-tooltip-id='${id}']`)

We should escape single quotes from id, so they're allowed to be used.

Will be fixed soon.

@gabrieljablonski
Copy link
Member

gabrieljablonski commented Apr 28, 2024

Fixed on react-tooltip@5.26.4

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

Successfully merging a pull request may close this issue.

2 participants