Open shahednasser opened 4 months ago
This is a well-known React issue, that crops up every few months on different projects I'm working on. Definitely extremely annoying.
Usually simply disabling translation for the whole page works well enough, but definitely a bad idea for the medusa docs here.
I'll have more time to try to work out a more permanent solution when using react-tooltip
, but until then, can you try the following and see if it works for you. It helps that you already have a wrapper component for the tooltip.
<span
id={elementId}
data-tooltip-content={text}
data-tooltip-html={html}
data-tooltip-id={elementId}
className={clsx(className, "notranslate")}
translate="no"
>
{children}
</span>
Adding className="notranslate"
+ translate="no"
attribute should disable browser translation for the tooltip anchor elements.
This might work well as a temporary fix, but we might be able to improve how the tooltip handles DOM changes internally.
Let us know what you find.
Hello! I tried your solution and I was only able to make it work by adding another wrapper span:
<span className={clsx(className, "notranslate")} translate="no"> // new
<span
id={elementId}
data-tooltip-content={text}
data-tooltip-html={html}
data-tooltip-id={elementId}
>
{children}
</span>
<ReactTooltip
anchorId={elementId}
// anchorSelect={elementId ? `#${elementId}` : undefined}
className={clsx(
"!text-compact-x-small !shadow-elevation-tooltip dark:!shadow-elevation-tooltip-dark !rounded-docs_DEFAULT",
"!py-docs_0.25 !z-[399] hidden !px-docs_0.5 lg:block",
"!bg-medusa-bg-component",
"!text-medusa-fg-base text-center",
tooltipClassName
)}
wrapper="span"
noArrow={true}
positionStrategy={"fixed"}
opacity={1}
{...tooltipProps}
>
{tooltipChildren}
</ReactTooltip>
</span>
Will use this fix for now, but yes would be great if we can get it fixed.
Thanks for the help! Not sure if I should close the issue so feel free to do so if it's not necessary anymore.
This issue is stale because it has not seen activity in 30 days. Remove the stale
label or comment within 14 days, or it will be closed.
Check the troubleshooting page before opening an issue!
Make sure your problem isn't already covered at the troubleshooting page: https://react-tooltip.com/docs/troubleshooting
Bug description
The Medusa documentation uses
react-tooltip
for all tooltips. We've had multiple users report an issue when using google translate (see here) where the website crashes with the errorNotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
After investigation, the error seems to result from google trying to replace the tooltip's content with the translated content.
Here's the error trace in development:
(Shortened the rest down for readability)
I confirmed that when i remove the use of
react-tooltip
in theTooltip
component, the issue doesn't occur anymore.This is the content of the
Tooltip
component:While this was reported on our documentation website running on Docusaurus, I was also able to reproduce it on our new documentation running on Next.js.
Version of Package v5.27.1
To Reproduce
Expected behavior The page shouldn't crash when using google translate
Screenshots
https://github.com/ReactTooltip/react-tooltip/assets/27354907/588e975e-11e4-41c4-9ef7-9c1bc39de35a
Desktop (please complete the following information if possible or delete this section):
Smartphone (please complete the following information if possible or delete this section):
Additional context Add any other context about the problem here.