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

Tooltip: this.tip.querySelector(...) is null #35375

Closed
3 tasks done
jwiesler opened this issue Nov 20, 2021 · 4 comments · Fixed by #34519
Closed
3 tasks done

Tooltip: this.tip.querySelector(...) is null #35375

jwiesler opened this issue Nov 20, 2021 · 4 comments · Fixed by #34519
Labels

Comments

@jwiesler
Copy link

jwiesler commented Nov 20, 2021

Prerequisites

Describe the issue

Changing data-bs-original-title of an empty html tooltip to some nonempty string causes this querySelector to return null on hover.

This happens since _sanitizeAndSetContent removes the .tooltip-inner element and the tip does not get updated before while the isWithContent check passes now. This might be fixed by regenerating the tooltip on hover.

Reduced test cases

https://codepen.io/OptimalSloth/pen/NWvJmbE

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

No response

What version of Bootstrap are you using?

5.1.3

@GeoSot
Copy link
Member

GeoSot commented Nov 20, 2021

I can confirm the case, but it is a bit strange case here. You want an empty tooltip to work, but with a 'custom not documented' way.

Anyway, Maybe changing this check,
this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML
with
this.getTitle() !== this._resolvePossibleFunction(this._config.title)

would help.

I would suggest not to use it, this way, but you can also try to make an MR with proposed changes

@jwiesler
Copy link
Author

I just want to change the content of the tooltip but setContent is not exported and not documented, even though it exists and searching for a way to do this brings up using this undocumented attribute.

If there is no way, I will just do a MR.

@GeoSot
Copy link
Member

GeoSot commented Nov 22, 2021

You are very right on what you said, and I do not know any valid way right now.
I am also trying to launch #34519 on next version, that may could do the job. You may give it a try

@jwiesler
Copy link
Author

Ok, I think I will wait for that, thank you.

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