]> source.dussan.org Git - vaadin-framework.git/commitdiff
Editor save/cancel buttons stay visually in place (#16562)
authorHenrik Paul <henrik@vaadin.com>
Tue, 3 Feb 2015 14:37:19 +0000 (16:37 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 4 Feb 2015 13:07:23 +0000 (13:07 +0000)
Change-Id: Ia63ffc36bee83e1bd20dc6e1a83616f94574a89b

client/src/com/vaadin/client/widgets/Grid.java
uitest/src/com/vaadin/testbench/elements/GridElement.java

index c8354dc5ce98ee36145a7f7ab52930b58ac0c1cc..ea69968a75c786c2b5e1583f60cc690710b131a1 100644 (file)
@@ -945,6 +945,10 @@ public class Grid<T> 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<T> 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<T> 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<T> 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) {
index 0c94c1dd88c308bcbacecc1b490c2c534753f285..784e67d8c2b109809eec0924501b4731597dcb66 100644 (file)
@@ -89,7 +89,6 @@ public class GridElement extends AbstractComponentElement {
          * useless.
          */
         public void save() {
-            getField(0);
             List<WebElement> 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<WebElement> buttons = findElements(By.xpath("./button"));
             buttons.get(1).click();
         }