diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-03-06 13:03:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 13:03:21 +0200 |
commit | 3397e396dcebb797006f1c4ae8186ea0d422a5f7 (patch) | |
tree | a4192ae4db5ef26c44582daafc0403a88af9ee9c /client | |
parent | d9c4969c4c32781cf65c1ea604bc96aecd85bfbf (diff) | |
download | vaadin-framework-3397e396dcebb797006f1c4ae8186ea0d422a5f7.tar.gz vaadin-framework-3397e396dcebb797006f1c4ae8186ea0d422a5f7.zip |
Further tweaks to ComboBox popup positioning. (#11910)
* Further tweaks to ComboBox popup positioning.
- Updated a comment and renamed a private method for better clarity.
- Blocked unnecessary position updates.
- Added a test for #11866 / #11894.
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VComboBox.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index 140d8e3ce4..cf06e06b2d 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -902,11 +902,16 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, int comboBoxLeft = VComboBox.this.getAbsoluteLeft(); int comboBoxWidth = VComboBox.this.getOffsetWidth(); - if (hasParentWithUnadjustedPositioning()) { - // ComboBox itself may be incorrectly positioned, don't adjust - // popup position yet. Width calculations must be performed - // anyway to avoid flickering. - setPopupPosition(left, top); + if (hasParentWithUnadjustedHorizontalPositioning()) { + // ComboBox itself may be incorrectly positioned, don't try to + // adjust horizontal popup position yet. Earlier width + // calculations must be performed anyway to avoid flickering. + if (top != topPosition) { + // Variable 'left' still contains the original popupLeft, + // 'top' has been updated, thus vertical position needs + // adjusting. + setPopupPosition(left, top); + } return; } if (left > comboBoxLeft @@ -929,7 +934,10 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, menu.setWidth(Window.getClientWidth() + "px"); } - setPopupPosition(left, top); + // Only update the position if it has changed. + if (top != topPosition || left != getPopupLeft()) { + setPopupPosition(left, top); + } menu.scrollSelectionIntoView(); } @@ -941,7 +949,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, * @return {@code true} if unadjusted parents found, {@code false} * otherwise */ - private boolean hasParentWithUnadjustedPositioning() { + private boolean hasParentWithUnadjustedHorizontalPositioning() { /* * If there are any VHorizontalLayouts among this VComboBox's * parents, any spacing or expand ratio may cause incorrect |