mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
Merge pull request #21694 from overleaf/jel-tooltip-when-needed
[web] Only add tooltip to badge links if badge is clipped GitOrigin-RevId: c99f3f0732ed6e8112c1af1063f64bcab152b00d
This commit is contained in:
parent
d6281424f4
commit
ce8781e79f
1 changed files with 16 additions and 0 deletions
|
@ -6,6 +6,10 @@ const footerLanguageElement = document.querySelector(
|
||||||
|
|
||||||
const allTooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
const allTooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
||||||
|
|
||||||
|
const possibleTooltips = document.querySelectorAll(
|
||||||
|
'[data-bs-toggle="tooltip-if-needed"]'
|
||||||
|
)
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const footLangTooltip = new Tooltip(footerLanguageElement)
|
const footLangTooltip = new Tooltip(footerLanguageElement)
|
||||||
|
|
||||||
|
@ -13,3 +17,15 @@ allTooltips.forEach(element => {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const tooltip = new Tooltip(element)
|
const tooltip = new Tooltip(element)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
possibleTooltips.forEach(element => {
|
||||||
|
// put data-bs-toggle="tooltip-if-needed" on .badge-content
|
||||||
|
// then tooltip is only shown if .badge is clipped due to max-width
|
||||||
|
if (
|
||||||
|
element.parentElement &&
|
||||||
|
element.scrollWidth > element.parentElement?.scrollWidth
|
||||||
|
) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const tooltip = new Tooltip(element)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue