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

UncontrolledTooltip should not raise an error when the target ID does not exist in the DOM #1593

Open
Muntaner opened this issue Jul 25, 2019 · 6 comments

Comments

@Muntaner
Copy link

Issue description

  • reactstrap version ^8.0.0
  • react version ^16.8.6

What is happening?

UncontrolledTooltip (and maybe other Uncontrolled components?) raise an error in the React application when the target ID does not exist in the DOM.

What should be happening?

Instead of raising an error which can make the whole React application crash (imho this does not seem to be a critical problem, but more of an UX one), maybe it should just warn the developer/user through the console and peacefully not show the tooltip.

Steps to reproduce issue

  1. Create an UncontrolledTooltip whose target does not exist in the DOM (or can exist or not in the DOM depending to the component state).

Error message in console

No error in console.

@rivalver
Copy link

rivalver commented Aug 7, 2019

Having the same issues with Uncontrolled Tooltips and Badges.

@alamothe
Copy link

alamothe commented Oct 2, 2019

+1

Also: #773, so sometimes it will crash even if the id is spelled correctly.

I think this should be console.error rather than crashing the whole app.

@modemmute
Copy link

Is there any progress on this?

@ahoran3
Copy link

ahoran3 commented Oct 2, 2021

Not sure why it this ticket hasnt been updated, but I've encountered the same issue using version 8.7.0.
It appears that a fix was made in 8.8.1 as per the tag release notes here.

@sevdog
Copy link

sevdog commented Aug 17, 2022

This issue is still present, even if in v8.8.1 a "safe-render" was added the problem is findDOMElements:

reactstrap/src/utils.js

Lines 297 to 301 in 551d9ee

if (!selection.length) {
throw new Error(
`The target '${target}' could not be identified in the dom, tip: check spelling`,
);
}

This issue is caused when tooltip and target are created togheter, thus the target does not yet exists in the DOM while the tooltip is moutend.

This happens only if the tooltip is open at first render (defaultOpen for uncontrolled tooltip).

@alamothe
Copy link

Definitely not fixed, we see frequent crashes in Sentry due to this.

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

No branches or pull requests

6 participants