From: Leif Åstrand Date: Mon, 6 Aug 2012 05:46:29 +0000 (+0000) Subject: Force horizontal scrolling with wide columns but no rows (#9187) X-Git-Tag: 7.0.0.beta1~79^2~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=27fc8ddc0087a3ac4367e4e50883bd859fa90dd4;p=vaadin-framework.git Force horizontal scrolling with wide columns but no rows (#9187) svn changeset:24065/svn branch:6.8 --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index e54493ca61..43e07376f4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -6091,16 +6091,39 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // Hey IE, are you really sure about this? availW = scrollBody.getAvailableWidth(); int visibleCellCount = tHead.getVisibleCellCount(); - availW -= scrollBody.getCellExtraWidth() * visibleCellCount; + int totalExtraWidth = scrollBody.getCellExtraWidth() + * visibleCellCount; if (willHaveScrollbars()) { - availW -= Util.getNativeScrollbarSize(); + totalExtraWidth += Util.getNativeScrollbarSize(); } - + availW -= totalExtraWidth; + int forceScrollBodyWidth = -1; + int extraSpace = availW - usedMinimumWidth; if (extraSpace < 0) { + if (getTotalRows() == 0) { + /* + * Too wide header combined with no rows in the table. + * + * No horizontal scrollbars would be displayed because + * there's no rows that grows too wide causing the + * scrollBody container div to overflow. Must explicitely + * force a width to a scrollbar. (see #9187) + */ + forceScrollBodyWidth = usedMinimumWidth + totalExtraWidth; + } extraSpace = 0; } + if (forceScrollBodyWidth > 0) { + scrollBody.container.getStyle().setWidth(forceScrollBodyWidth, + Unit.PX); + } else { + // Clear width that might have been set to force horizontal + // scrolling if there are no rows + scrollBody.container.getStyle().clearWidth(); + } + int totalUndefinedNaturalWidths = usedMinimumWidth - totalExplicitColumnsWidths; diff --git a/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html b/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html new file mode 100644 index 0000000000..98629252d9 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html @@ -0,0 +1,86 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item023,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item533,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item150,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item054,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item128,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item029,5
dragvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]0,7
dropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]150,7
screenCapture1-wide-header
dragvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]0,7
dropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]-152,7
screenCapture2-narrow-header
+ +