diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2018-10-08 15:08:05 +0300 |
---|---|---|
committer | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2018-10-08 15:08:05 +0300 |
commit | a174deeac87899960f136f4675f9146785da2413 (patch) | |
tree | bcc0476ec5cf5253bd1dba6e547d0310dec894f4 /client | |
parent | 24c45ba8f1b0cdc7d0d6ce9e23f23f9b65d15a4a (diff) | |
download | vaadin-framework-a174deeac87899960f136f4675f9146785da2413.tar.gz vaadin-framework-a174deeac87899960f136f4675f9146785da2413.zip |
Fixes to displaying Grid in a detail row. (#11147)
- Multiple headers shouldn't stack behind each other.
- Body rows shouldn't get stuck to default row height.
- Compatibility version's hidable row selector shouldn't try to
calculate row heights based on rows that haven't been added to DOM yet.
Fixes #7674
Diffstat (limited to 'client')
3 files changed, 37 insertions, 4 deletions
diff --git a/client/src/main/java/com/vaadin/client/widget/escalator/RowContainer.java b/client/src/main/java/com/vaadin/client/widget/escalator/RowContainer.java index 26a2f294b7..7ef6ff6bbf 100644 --- a/client/src/main/java/com/vaadin/client/widget/escalator/RowContainer.java +++ b/client/src/main/java/com/vaadin/client/widget/escalator/RowContainer.java @@ -236,6 +236,14 @@ public interface RowContainer { public int getRowCount(); /** + * For internal use only. May be removed or replaced in the future. + * + * @since + * @return {@code true} if row height calculations have been scheduled + */ + public boolean isAutodetectingRowHeightLater(); + + /** * The default height of the rows in this RowContainer. * * @param px diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index a3ecfab902..393708f7da 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -1274,6 +1274,8 @@ public class Escalator extends Widget private boolean initialColumnSizesCalculated = false; + private boolean autodetectingRowHeightLater = false; + public AbstractRowContainer( final TableSectionElement rowContainerElement) { root = rowContainerElement; @@ -2115,14 +2117,21 @@ public class Escalator extends Widget } public void autodetectRowHeightLater() { + autodetectingRowHeightLater = true; Scheduler.get().scheduleFinally(() -> { if (defaultRowHeightShouldBeAutodetected && isAttached()) { autodetectRowHeightNow(); defaultRowHeightShouldBeAutodetected = false; } + autodetectingRowHeightLater = false; }); } + @Override + public boolean isAutodetectingRowHeightLater() { + return autodetectingRowHeightLater; + } + private void fireRowHeightChangedEventFinally() { if (!rowHeightChangedEventFired) { rowHeightChangedEventFired = true; diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index e6efe4cbc0..f42312c1d6 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -76,10 +76,7 @@ import com.google.gwt.user.client.ui.MenuItem; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.ResizeComposite; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.BrowserInfo; -import com.vaadin.client.DeferredWorker; -import com.vaadin.client.Focusable; -import com.vaadin.client.WidgetUtil; +import com.vaadin.client.*; import com.vaadin.client.WidgetUtil.Reference; import com.vaadin.client.data.DataChangeHandler; import com.vaadin.client.data.DataSource; @@ -3342,6 +3339,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, */ private class AutoColumnWidthsRecalculator { private double lastCalculatedInnerWidth = -1; + private double lastCalculatedInnerHeight = -1; private final ScheduledCommand calculateCommand = new ScheduledCommand() { @@ -3436,6 +3434,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, // Update latest width to prevent recalculate on height change. lastCalculatedInnerWidth = escalator.getInnerWidth(); + lastCalculatedInnerHeight = getEscalatorInnerHeight(); } private boolean columnsAreGuaranteedToBeWiderThanGrid() { @@ -9148,6 +9147,18 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, recalculateColumnWidths(); } + + if (getEscalatorInnerHeight() != autoColumnWidthsRecalculator.lastCalculatedInnerHeight) { + Scheduler.get().scheduleFinally(() -> { + // Trigger re-calculation of all row positions. + RowContainer.BodyRowContainer body = getEscalator() + .getBody(); + if (!body.isAutodetectingRowHeightLater()) { + body.setDefaultRowHeight(body.getDefaultRowHeight()); + } + }); + } + // Vertical resizing could make editor positioning invalid so it // needs to be recalculated on resize if (isEditorActive()) { @@ -9161,6 +9172,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, }); } + private double getEscalatorInnerHeight() { + return new ComputedStyle(getEscalator().getTableWrapper()) + .getHeightIncludingBorderPadding(); + } + /** * Grid does not support adding Widgets this way. * <p> |