]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed theming issues with Grid's Sidebar (#17412)
authorPekka Hyvönen <pekka@vaadin.com>
Wed, 22 Apr 2015 14:17:18 +0000 (17:17 +0300)
committerPekka Hyvönen <pekka@vaadin.com>
Wed, 22 Apr 2015 14:53:46 +0000 (17:53 +0300)
- if columns hidable when grid rendered, sidebar button had invalid height
- removed border radius from grid sidebar
- inherit font color for grid sidebar button

Change-Id: Ib35d917b35e701bd736a28f19b34dbece7fcbe71

WebContent/VAADIN/themes/base/grid/grid.scss
client/src/com/vaadin/client/widgets/Grid.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSidebarFeatures.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSidebarThemeTest.java

index 838c0de5023c2944ccaad9b02133ad8501144b87..ee503822b98a41461e0e8ecf03e5fe9f07f2178f 100644 (file)
@@ -90,6 +90,7 @@ $v-grid-details-border-bottom-stripe: 1px solid darken($v-grid-row-background-co
 
   .#{$primaryStyleName}-sidebar.v-contextmenu {
     @include box-shadow(none);
+    border-radius: 0;
     position: absolute;
     top: 0;
     right: 0;
@@ -102,6 +103,7 @@ $v-grid-details-border-bottom-stripe: 1px solid darken($v-grid-row-background-co
     .#{$primaryStyleName}-sidebar-button {
       background: transparent;
       border: none;
+      color: inherit;
       cursor: pointer;
       outline: none;
       padding: 0 4px;
@@ -133,7 +135,7 @@ $v-grid-details-border-bottom-stripe: 1px solid darken($v-grid-row-background-co
           line-height: 1;
         }
       }
-    }      
+    }
 
     .v-ie &.opened .#{$primaryStyleName}-sidebar-button {
       vertical-align: middle;
@@ -144,7 +146,6 @@ $v-grid-details-border-bottom-stripe: 1px solid darken($v-grid-row-background-co
     }
 
     .#{$primaryStyleName}-sidebar-content {
-      background: #fff;
       border-top: $v-grid-border;
       padding: 4px 0;
 
index 0934d61eeb5fcd943624816a507f6db0868626c0..65d1173ee4f7c8fcfb1ca2b38b3167ca0a4ab2ee 100644 (file)
@@ -3191,6 +3191,20 @@ public class Grid<T> extends ResizeComposite implements
         private boolean isInDOM() {
             return getParent() != null;
         }
+
+        @Override
+        protected void onAttach() {
+            super.onAttach();
+            // make sure the button will get correct height if the button should
+            // be visible when the grid is rendered the first time.
+            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+
+                @Override
+                public void execute() {
+                    setHeightToHeaderCellHeight();
+                }
+            });
+        }
     }
 
     /**
index 2abd603ae4b3f292c61a87923320fca49b0f3f64..8c60deaf3c35a611635c543e8e0318de9fb64e12 100644 (file)
@@ -291,7 +291,9 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
 
         // Set varying column widths
         for (int col = 0; col < COLUMNS; col++) {
-            grid.getColumn(getColumnProperty(col)).setWidth(100 + col * 50);
+            Column column = grid.getColumn(getColumnProperty(col));
+            column.setWidth(100 + col * 50);
+            column.setHidable(isColumnHidableByDefault(col));
         }
 
         grid.addSortListener(new SortListener() {
@@ -334,6 +336,14 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
         return grid;
     }
 
+    protected boolean isColumnHidableByDefault(int col) {
+        return false;
+    }
+
+    protected boolean isColumnHiddenByDefault(int col) {
+        return false;
+    }
+
     private void addInternalActions() {
         createClickAction("Update column order without updating client",
                 "Internals", new Command<Grid, Void>() {
@@ -828,8 +838,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
                         }
                     }, c);
 
-            createBooleanAction("Hidable", getColumnProperty(c), false,
-                    new Command<Grid, Boolean>() {
+            createBooleanAction("Hidable", getColumnProperty(c),
+                    isColumnHidableByDefault(c), new Command<Grid, Boolean>() {
                         @Override
                         public void execute(Grid c, Boolean hidable,
                                 Object propertyId) {
@@ -837,8 +847,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
                         }
                     }, getColumnProperty(c));
 
-            createBooleanAction("Hidden", getColumnProperty(c), false,
-                    new Command<Grid, Boolean>() {
+            createBooleanAction("Hidden", getColumnProperty(c),
+                    isColumnHiddenByDefault(c), new Command<Grid, Boolean>() {
                         @Override
                         public void execute(Grid c, Boolean hidden,
                                 Object propertyId) {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSidebarFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridSidebarFeatures.java
new file mode 100644 (file)
index 0000000..9494988
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid.basicfeatures;
+
+public class GridSidebarFeatures extends GridBasicFeatures {
+
+    @Override
+    protected boolean isColumnHidableByDefault(int col) {
+        return true;
+    }
+}
index 79327993b01344b94f9114c0bfef8d22347f3f76..5262156b417571ad94806edf230b8e5d8e947087 100644 (file)
@@ -19,13 +19,11 @@ import java.io.IOException;
 import java.util.List;
 
 import org.junit.Test;
-import org.openqa.selenium.By;
 import org.openqa.selenium.interactions.Actions;
 import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedConditions;
 
-import com.vaadin.testbench.parallel.Browser;
 import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+import com.vaadin.tests.components.grid.basicfeatures.GridSidebarFeatures;
 
 public class GridSidebarThemeTest extends GridBasicFeaturesTest {
 
@@ -34,18 +32,18 @@ public class GridSidebarThemeTest extends GridBasicFeaturesTest {
         runTestSequence("valo");
     }
 
+    @Test
+    public void testValoDark() throws Exception {
+        runTestSequence("tests-valo-dark");
+    }
+
+    @Override
+    protected Class<?> getUIClass() {
+        return GridSidebarFeatures.class;
+    }
+
     private void runTestSequence(String theme) throws IOException {
         openTestURL("theme=" + theme);
-        if (getDesiredCapabilities().getBrowserName().equals(
-                Browser.CHROME.getDesiredCapabilities().getBrowserName())) {
-            waitUntil(ExpectedConditions.elementToBeClickable(By.id("menu")), 2);
-            getDriver().findElement(By.id("menu")).click();
-            selectMenu("Columns");
-            selectMenu("All columns hidable");
-            waitUntilLoadingIndicatorNotVisible();
-        } else {
-            selectMenuPath("Component", "Columns", "All columns hidable");
-        }
 
         compareScreen(theme + "|SidebarClosed");
         getSidebarOpenButton().click();