Skip to content

Commit

Permalink
[BUGFIX] Initialize tooltips only once
Browse files Browse the repository at this point in the history
Due to several modules initializing tooltips, it might happen that they
are initializing the same element twice or even more times. This can be
easily avoided by using the new bootstrap Tooltip method
"getOrCreateInstance". This should fix weird behaviour, where the
tooltip did not disappear.

Also, since updating to a newer bootstrap version the fix 0005bc5 did
not work anymore. This is fixed by using the container context as
selector basis.

Resolves: #94477
Releases: master
Change-Id: Iea67db7fe63825f2eba028302d435cf7e2c8e7b8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70119
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
nhovratov authored and bmack committed Jul 28, 2021
1 parent 62be650 commit 3748caf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Expand Up @@ -1127,7 +1127,7 @@ export class SvgTree extends LitElement {
this.scrollBottom = this.scrollTop + this.viewportHeight + (this.viewportHeight / 2);
// wait for the tooltip to appear and disable tooltips when scrolling
setTimeout(() => {
Tooltip.hide(this.querySelectorAll('.bs-tooltip-end'));
Tooltip.hide(document.querySelector(<string>this.tooltipOptions.container).querySelectorAll('.bs-tooltip-end'));
}, <number>this.tooltipOptions.delay)
}

Expand Down
Expand Up @@ -45,7 +45,12 @@ class Tooltip {
}
const elements = document.querySelectorAll(selector);
for (const element of elements) {
new BootstrapTooltip(element, options);
// @ts-ignore
// todo this method is missing in types/bootstrap.
// todo see: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/54289
// todo Remove ts-ignore, when it is added.
// Ensure elements are not initialized multiple times.
BootstrapTooltip.getOrCreateInstance(element, options);
}
}

Expand Down

0 comments on commit 3748caf

Please sign in to comment.