use offsetWidth to decide if the button text is ellipsized
This commit is contained in:
parent
78080df6fd
commit
154187f1bc
13
js/dom.js
13
js/dom.js
|
@ -28,14 +28,15 @@ $$.remove = (selector, base = document) => {
|
||||||
// display a full text tooltip on buttons with ellipsis overflow and no inherent title
|
// display a full text tooltip on buttons with ellipsis overflow and no inherent title
|
||||||
const addTooltipsToEllipsized = () => {
|
const addTooltipsToEllipsized = () => {
|
||||||
for (const btn of document.getElementsByTagName('button')) {
|
for (const btn of document.getElementsByTagName('button')) {
|
||||||
if (btn.title && !btn.titleIsForEllipsis ||
|
if (btn.title && !btn.titleIsForEllipsis) {
|
||||||
btn.clientWidth === btn.preresizeClientWidth) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
btn.preresizeClientWidth = btn.clientWidth;
|
const width = btn.offsetWidth;
|
||||||
const padding = btn.offsetWidth - btn.clientWidth;
|
if (!width || btn.preresizeClientWidth === width) {
|
||||||
const displayedWidth = btn.getBoundingClientRect().width - padding;
|
continue;
|
||||||
if (btn.scrollWidth > displayedWidth) {
|
}
|
||||||
|
btn.preresizeClientWidth = width;
|
||||||
|
if (btn.scrollWidth > width) {
|
||||||
const text = btn.textContent;
|
const text = btn.textContent;
|
||||||
btn.title = text.includes('\u00AD') ? text.replace(/\u00AD/g, '') : text;
|
btn.title = text.includes('\u00AD') ? text.replace(/\u00AD/g, '') : text;
|
||||||
btn.titleIsForEllipsis = true;
|
btn.titleIsForEllipsis = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user