diff options
author | Artur Signell <artur@vaadin.com> | 2015-06-01 22:17:10 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-06-05 11:25:50 +0000 |
commit | 96e0e2ed125a05d58373e1a6c11d8bfe39659e89 (patch) | |
tree | 2bae6e7b9de2859b6c8de9fe270389f19194df55 | |
parent | 27f574154b5e27407370b6e072e5fa13d1d97797 (diff) | |
download | vaadin-framework-96e0e2ed125a05d58373e1a6c11d8bfe39659e89.tar.gz vaadin-framework-96e0e2ed125a05d58373e1a6c11d8bfe39659e89.zip |
Only set height when at least one header cell is shown (#18000)
Change-Id: I252a8223804b5ba45abb20061c3d65d0b80603dc
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 33 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java | 24 |
2 files changed, 38 insertions, 19 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 079207a999..67220b6e07 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -3238,27 +3238,22 @@ public class Grid<T> extends ResizeComposite implements } private void setHeightToHeaderCellHeight() { - try { - double height = WidgetUtil - .getRequiredHeightBoundingClientRectDouble(grid.escalator - .getHeader().getRowElement(0) - .getFirstChildElement()) - - (WidgetUtil.measureVerticalBorder(getElement()) / 2); - openCloseButton.setHeight(height + "px"); - } catch (NullPointerException npe) { - getLogger() - .warning( - "Got null header first row or first row cell when calculating sidebar button height"); - openCloseButton.setHeight(grid.escalator.getHeader() - .getDefaultRowHeight() + "px"); - } catch (IndexOutOfBoundsException ioobe) { - // happens when escalator doesn't have any headers rendered yet. + RowContainer header = grid.escalator.getHeader(); + if (header.getRowCount() == 0 + || !header.getRowElement(0).hasChildNodes()) { getLogger() - .warning( - "No header cell available when calculating sidebar button height"); - openCloseButton.setHeight(grid.escalator.getHeader() - .getDefaultRowHeight() + "px"); + .info("No header cell available when calculating sidebar button height"); + openCloseButton.setHeight(header.getDefaultRowHeight() + "px"); + + return; } + + Element firstHeaderCell = header.getRowElement(0) + .getFirstChildElement(); + double height = WidgetUtil + .getRequiredHeightBoundingClientRectDouble(firstHeaderCell) + - (WidgetUtil.measureVerticalBorder(getElement()) / 2); + openCloseButton.setHeight(height + "px"); } private void updateVisibility() { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java index c4ad2ea347..9f63c2b177 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java @@ -840,6 +840,30 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest { .getDetails(1)); } + @Test + public void testHideShowAllColumns() { + selectMenuPath("Component", "State", "Width", "1000px"); + int colCount = 12; + for (int i = 0; i < colCount; i++) { + toggleHidableColumnAPI(i); + } + clickSidebarOpenButton(); + for (int i = 0; i < colCount; i++) { + getColumnHidingToggle(i).click(); + } + + clickSidebarOpenButton(); + // All columns hidden + assertEquals(0, getGridHeaderRowCells().size()); + clickSidebarOpenButton(); + for (int i = 0; i < colCount; i++) { + getColumnHidingToggle(i).click(); + } + + assertEquals(colCount, getGridHeaderRowCells().size()); + + } + private void loadSpannedCellsFixture() { selectMenuPath("Component", "State", "Width", "1000px"); appendHeaderRow(); |