question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

5.2.0 regression: tooltips never close when they are initialized using as `selector` option the attribute `title`

See original GitHub issue

Prerequisites

Describe the issue

Hi,

Since Bootstrap v5.2.0, the tooltips never close when they are initialized with selector option. It worked fine under Bootstrap v5.1.3. So, I think there is a regression.

HTML:

<div id="btn-box" class="btn-group m-5">
  <button class="btn btn-lg btn-primary" title="Label 1">Button 1</button>
  <button class="btn btn-lg btn-secondary" title="Label 2">Button 2</button>
</div>

JavaScript:

new bootstrap.Tooltip('#btn-box', {
    selector: '[title]'
});

Reduced test cases

The tooltip is hidden when the mouse leaves the element Version selector option CodePen link
✔️ 5.1.3 https://codepen.io/BrokenSourceCode/pen/zYWzZNJ
✔️ 5.1.3 ✔️ https://codepen.io/BrokenSourceCode/pen/vYRZxNo
✔️ 5.2.0 https://codepen.io/BrokenSourceCode/pen/GRxEWWp
5.2.0 ✔️ https://codepen.io/BrokenSourceCode/pen/ExEXWPp

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

Windows

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

Chrome

What version of Bootstrap are you using?

v5.2.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Bugophobiacommented, Sep 12, 2022

Not fixed in 5.2.1

@GeoSot said it won’t be fixed, because this is a bad practice. See https://github.com/twbs/bootstrap/issues/36813#issuecomment-1195141449. You can use another selector like [data-bs-toggle="tooltip"] or as well use your own custom class. The solution below will show you how to fix your issue.

HTML:

<!-- For `[data-bs-toggle="tooltip"]` selector. -->
<button class="btn btn-lg btn-info" title="Label 1" data-bs-toggle="tooltip">Button 1</button>
<button class="btn btn-lg btn-success" title="Label 2" data-bs-toggle="tooltip">Button 2</button>

<!-- For `.toggle-tooltip` selector. -->
<button class="btn btn-lg btn-warning toggle-tooltip" title="Label 3">Button 3</button>
<button class="btn btn-lg btn-danger toggle-tooltip" title="Label 4">Button 4</button>

JavaScript:

new bootstrap.Tooltip('body', {
    selector: '[data-bs-toggle="tooltip"], .toggle-tooltip'
});

Furthermore, @GeoSot, I suggest adding a note in the documentation of the selector option to state that the title attribute MUST NOT be used as selector.

1

1reaction
saturdaywalkerscommented, Sep 13, 2022

Thanks @BrokenSourceCode !

Turned out quite easy to fix… just grep the js html templates for title= and add a target to use in a selector, data-bs-tooltip in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog | Docs - TinyMCE
Fixed a regression that caused block wrapper formats to apply and remove incorrectly when using a collapsed selection with multiple words.
Read more >
Releases - MudBlazor - Blazor Component Library
- Reverted MudAutoComplete close on blur from MudBlazor 5.0.12 that did not select the selected option. #MudBlazor 5.0.12. - MudTextField Added missing right ......
Read more >
Tooltips and Popovers not working in Bootstrap 5
In current implementation, the code to enable tooltips and popovers everywhere is not run by default. You have to run it yourself, ...
Read more >
Changelog - Cypress Documentation
Fixed a regression introduced in the Electron browser in Cypress 10.8.0 where the CYPRESS_EVERY_NTH_FRAME environment variable was not being set appropriately ...
Read more >
Bootstrap Tooltips - examples & tutorial
Tooltips are opt-in for performance reasons, so you must initialize them yourself. Tooltips with zero-length titles are never displayed. Specify container: ' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found