From: Henrik Paul Date: Tue, 3 Feb 2015 14:37:19 +0000 (+0200) Subject: Editor save/cancel buttons stay visually in place (#16562) X-Git-Tag: 7.5.0.alpha1~149 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=103b177475e0029abed00eec68e752492feafa61;p=vaadin-framework.git Editor save/cancel buttons stay visually in place (#16562) Change-Id: Ia63ffc36bee83e1bd20dc6e1a83616f94574a89b --- diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index c8354dc5ce..ea69968a75 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -945,6 +945,10 @@ public class Grid extends ResizeComposite implements private static final double BUTTON_HEIGHT = 25; private static final double BUTTON_WIDTH = 50; private static final double BUTTON_MARGIN = 5; + private static final double SAVE_BUTTON_LEFT_MARGIN_PX = 0; + private static final double CANCEL_BUTTON_LEFT_MARGIN_PX = SAVE_BUTTON_LEFT_MARGIN_PX + + BUTTON_WIDTH + BUTTON_MARGIN; + public static final int KEYCODE_SHOW = KeyCodes.KEY_ENTER; public static final int KEYCODE_HIDE = KeyCodes.KEY_ESCAPE; @@ -1264,8 +1268,6 @@ public class Grid extends ResizeComposite implements setBounds(editorOverlay, tr.getOffsetLeft(), overlayTop, width, height); - updateHorizontalScrollPosition(); - scrollHandler = grid.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { @@ -1321,10 +1323,12 @@ public class Grid extends ResizeComposite implements * Chrome and Firefox. So we measure it. */ double buttonTop = getButtonTop(tr, saveButton.getOffsetHeight()); - setBounds(saveButton.getElement(), 0, buttonTop, BUTTON_WIDTH, - BUTTON_HEIGHT); - setBounds(cancelButton.getElement(), BUTTON_WIDTH + BUTTON_MARGIN, + setBounds(saveButton.getElement(), SAVE_BUTTON_LEFT_MARGIN_PX, + buttonTop, BUTTON_WIDTH, BUTTON_HEIGHT); + setBounds(cancelButton.getElement(), CANCEL_BUTTON_LEFT_MARGIN_PX, buttonTop, BUTTON_WIDTH, BUTTON_HEIGHT); + + updateHorizontalScrollPosition(); } private double getButtonTop(TableRowElement tr, int buttonHeight) { @@ -1406,7 +1410,14 @@ public class Grid extends ResizeComposite implements } private void updateHorizontalScrollPosition() { - editorOverlay.getStyle().setLeft(-grid.getScrollLeft(), Unit.PX); + double scrollLeft = grid.getScrollLeft(); + + editorOverlay.getStyle().setLeft(-scrollLeft, Unit.PX); + + double saveLeftPx = scrollLeft + SAVE_BUTTON_LEFT_MARGIN_PX; + double cancelLeftPx = scrollLeft + CANCEL_BUTTON_LEFT_MARGIN_PX; + saveButton.getElement().getStyle().setLeft(saveLeftPx, Unit.PX); + cancelButton.getElement().getStyle().setLeft(cancelLeftPx, Unit.PX); } protected void setGridEnabled(boolean enabled) { diff --git a/uitest/src/com/vaadin/testbench/elements/GridElement.java b/uitest/src/com/vaadin/testbench/elements/GridElement.java index 0c94c1dd88..784e67d8c2 100644 --- a/uitest/src/com/vaadin/testbench/elements/GridElement.java +++ b/uitest/src/com/vaadin/testbench/elements/GridElement.java @@ -89,7 +89,6 @@ public class GridElement extends AbstractComponentElement { * useless. */ public void save() { - getField(0); List buttons = findElements(By.xpath("./button")); buttons.get(0).click(); } @@ -101,7 +100,6 @@ public class GridElement extends AbstractComponentElement { * useless. */ public void cancel() { - getField(0); List buttons = findElements(By.xpath("./button")); buttons.get(1).click(); }