summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-04-29 10:33:54 +0300
committerGitHub <noreply@github.com>2020-04-29 10:33:54 +0300
commit4c9a5405a555785dc2b38e82b3d1cda0336491e0 (patch)
tree75ba4ed2247f48255f6a51ba076c5f702487f2dd /client
parent599387b330f66f0dbe6087d2fe829bc251fef6c1 (diff)
downloadvaadin-framework-4c9a5405a555785dc2b38e82b3d1cda0336491e0.tar.gz
vaadin-framework-4c9a5405a555785dc2b38e82b3d1cda0336491e0.zip
Fix the column width calculations for full width cell contents. (#11974)
Fixes #11973
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/Escalator.java40
1 files changed, 40 insertions, 0 deletions
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 c2e70eeb96..b4427b2df1 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
@@ -37,6 +37,7 @@ import com.google.gwt.animation.client.AnimationScheduler;
import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback;
import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle;
import com.google.gwt.core.client.Duration;
+import com.google.gwt.core.client.JavaScriptException;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.Scheduler;
@@ -2240,6 +2241,10 @@ public class Escalator extends Widget
TableCellElement cellClone = TableCellElement
.as((Element) cell.cloneNode(withContent));
+ if (!withContent || columnConfiguration
+ .getColumnWidth(cell.getCellIndex()) < 0) {
+ clearRelativeWidthContents(cellClone);
+ }
cellClone.getStyle().clearHeight();
cellClone.getStyle().clearWidth();
@@ -2260,6 +2265,41 @@ public class Escalator extends Widget
}
/**
+ * Contents of an element that is configured to have relative width
+ * shouldn't be taken into consideration when measuring minimum widths.
+ * Thus any such contents within the element hierarchy need to be
+ * cleared out for accurate results. The element itself should remain,
+ * however, in case it has styles that affect the end results.
+ *
+ * @param elem
+ * an element that might have unnecessary content that
+ * interferes with minimum width calculations
+ */
+ private void clearRelativeWidthContents(Element elem) {
+ try {
+ String width = elem.getStyle().getWidth();
+ if (width != null && width.endsWith("%")) {
+ if (elem.hasChildNodes()) {
+ elem.removeAllChildren();
+ // add a fake child so that :empty behavior doesn't
+ // change
+ elem.setInnerHTML("<a/>");
+ } else {
+ elem.setInnerHTML(null);
+ }
+ }
+ } catch (JavaScriptException e) {
+ // no width set, move on
+ }
+ for (int i = 0; i < elem.getChildCount(); ++i) {
+ Node node = elem.getChild(i);
+ if (node instanceof Element) {
+ clearRelativeWidthContents((Element) node);
+ }
+ }
+ }
+
+ /**
* Gets the minimum width needed to display the cell properly.
*
* @param colIndex