@@ -47,7 +47,8 @@ class DropdownPopup {
4747 private static final int BORDER_ARC = 8 ;
4848 private static final int ITEM_FOCUS_ARC = 6 ;
4949 private static final int MAX_VISIBLE_ITEMS = 15 ;
50- private static final int MAX_HOVER_WIDTH = 300 ;
50+ private static final int SHORT_POPUP_WIDTH = 230 ;
51+ private static final int LONG_POPUP_WIDTH = 300 ;
5152
5253 private static Image checkIcon ;
5354
@@ -214,6 +215,7 @@ void open(Point location, List<DropdownItemGroup> groups, String selectedItemId,
214215 });
215216
216217 shell .pack ();
218+ shell .setSize (SHORT_POPUP_WIDTH , shell .getSize ().y );
217219 constrainHeightIfNeeded ();
218220 adjustBounds (location , anchorHeight );
219221 scrollToFocusedItem ();
@@ -496,10 +498,11 @@ private void openHoverShell(DropdownItem item, Composite anchorItem) {
496498
497499 hoverShell .pack ();
498500 Point hoverSize = hoverShell .getSize ();
499- if (hoverSize .x > MAX_HOVER_WIDTH ) {
500- // Recompute height at the constrained width so wrapped labels get enough space.
501- hoverSize = hoverShell .computeSize (MAX_HOVER_WIDTH , SWT .DEFAULT );
502- hoverSize .x = MAX_HOVER_WIDTH ;
501+ int width = hoverSize .x <= SHORT_POPUP_WIDTH ? SHORT_POPUP_WIDTH : LONG_POPUP_WIDTH ;
502+ if (width != hoverSize .x ) {
503+ // Recompute size at the target width so wrapped labels lay out correctly.
504+ hoverSize = hoverShell .computeSize (width , SWT .DEFAULT );
505+ hoverSize .x = width ;
503506 hoverShell .setSize (hoverSize );
504507 }
505508
0 commit comments