The same code is used once in widget toolkit and twice in PVE already,
so it makes sense to add it as a separate function.

Signed-off-by: Matthias Heiserer <m.heise...@proxmox.com>
---
 src/Utils.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/Utils.js b/src/Utils.js
index 6a03057..27fcd1d 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1272,6 +1272,17 @@ utilities: {
            .map(val => val.charCodeAt(0)),
        );
     },
+
+    calculateWidth: function(btn) {
+       // HACK: calculate the max button width on first render to avoid 
toolbar glitches
+       let defSize = btn.getSize().width;
+
+       btn.setText(btn.altText);
+       let altSize = btn.getSize().width;
+
+       btn.setText(btn.defaultText);
+       btn.setWidth(altSize > defSize ? altSize : defSize);
+    },
 },
 
     singleton: true,
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to