fix(web): fix documentation-keyboard spacebar-text scaling

Fixes: #12231
This commit is contained in:
Joshua A. Horton 2024-08-20 14:19:14 +07:00
parent 5bf42c5e24
commit 97697b695f

View file

@ -1246,6 +1246,7 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
const groupStyle = getComputedStyle(this.layerGroup.element);
const isInDOM = computedStyle.height != '' && computedStyle.height != 'auto';
const isGroupInDOM = groupStyle.height != '' && groupStyle.height != 'auto';
if (computedStyle.border) {
this._borderWidth = new ParsedLengthStyle(computedStyle.borderWidth).val;
@ -1258,10 +1259,11 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
this._computedHeight = this.height;
} else if (isInDOM) {
this._computedWidth = parseInt(computedStyle.width, 10);
if (!this._computedWidth) {
this._computedWidth = parseInt(groupStyle.width, 10);
}
this._computedHeight = parseInt(computedStyle.height, 10);
} else if (isGroupInDOM) {
// May occur for documentation-keyboards, which are detached from their VisualKeyboard base.
this._computedWidth = parseInt(groupStyle.width, 10);
this._computedHeight = parseInt(groupStyle.height, 10);
} else {
// Cannot perform layout operations!
return;
@ -1604,6 +1606,11 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
// the page.
kbdObj.appendStyleSheet();
// Unset the width + height we used thus far; this method's consumer may choose to rescale
// the returned element. If so, we don't want to use our outdated value by mistake.
delete kbdObj._width;
delete kbdObj._height;
return classWrapper;
}