From c60dcba7695729dbab1372d0efd62b1442bf29cc Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Sat, 27 Jun 2020 13:28:36 -0400 Subject: [PATCH] Be smarter about positioning the labeled edit menu (re: #7577) --- modules/ui/edit_menu.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/ui/edit_menu.js b/modules/ui/edit_menu.js index c5a95f0cc..d436d64b2 100644 --- a/modules/ui/edit_menu.js +++ b/modules/ui/edit_menu.js @@ -48,7 +48,16 @@ export function uiEditMenu(context) { var showLabels = isTouchMenu; var buttonHeight = showLabels ? 32 : 34; - var menuWidth = showLabels ? 172 : 44; + var menuWidth; + if (showLabels) { + // Get a general idea of the width based on the length of the label + menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) { + return op.title.length; + }))); + } else { + menuWidth = 44; + } + var menuLeft = displayOnLeft(viewport); offset[0] = menuLeft ? -1 * (_menuSideMargin + menuWidth) : _menuSideMargin;