When you:
It doesn't matter if the CSS variable actually exists or not, and it doesn't matter if I use var() with 1 argument or 2.
This problem doesn't occur when the exact same things occur but the border color is specified directly (ie. no var()).
I have two cases:
And the results look like this:
-> When first entering the page:
-> After 1 second when the Timers fire:
See how the red border is outside its constraints?
SmartClient Version: SNAPSHOT_v13.1d_2023-08-22/LGPL Development Only (built 2023-08-22)
- use Canvas.setBorder() on a HLayout after the HLayout has been created
- ... and the HLayout is placed in a VLayout
- ... and there is another widget below this HLayout
- ... and where the border color is set from a CSS var()
It doesn't matter if the CSS variable actually exists or not, and it doesn't matter if I use var() with 1 argument or 2.
This problem doesn't occur when the exact same things occur but the border color is specified directly (ie. no var()).
I have two cases:
- After the border is set, the HLayout expands to the right, beyond its containers size (shown in the example below).
- After the border is set, the HLayout shrinks vertically, with widgets below it encroaching on its space (I can't reproduce this in a minimal example).
Code:
import com.google.gwt.user.client.Timer; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; public class BorderWoes extends HLayout { public BorderWoes() { createVar(); this.addMember(createCssVarLayout()); this.addMember(createCssPlainColorLayout()); this.setPadding(5); this.setMembersMargin(30); this.draw(); } private static native void createVar() /*-{ $doc.querySelector(":root").style.setProperty("--foo-frame", "red"); }-*/; /** * cssVarBorder layout grows to the right after color change. */ private Layout createCssVarLayout() { VLayout layout = new VLayout(); layout.setBackgroundColor("yellow"); layout.setWidth("300px"); layout.setHeight("100px"); HLayout cssVarBorder = new HLayout(); cssVarBorder.addMember(new Label("CSS VAR")); cssVarBorder.setBorder("5px solid black"); new Timer() { @Override public void run() { cssVarBorder.setBorder("5px solid var(--foo-frame, blue)"); } }.schedule(1000); layout.addMember(cssVarBorder); layout.addMember(new Label("AFTER BORDER")); return layout; } /** * cssPlainColorBorder layout stays the same size */ private Layout createCssPlainColorLayout() { VLayout layout = new VLayout(); layout.setBackgroundColor("lightgray"); layout.setWidth("300px"); layout.setHeight("100px"); HLayout cssPlainColorBorder = new HLayout(); cssPlainColorBorder.addMember(new Label("CSS COLOR")); cssPlainColorBorder.setBorder("5px solid black"); new Timer() { @Override public void run() { cssPlainColorBorder.setBorder("5px solid blue"); } }.schedule(1000); layout.addMember(cssPlainColorBorder); layout.addMember(new Label("AFTER BORDER")); return layout; } }
-> When first entering the page:
-> After 1 second when the Timers fire:
See how the red border is outside its constraints?
SmartClient Version: SNAPSHOT_v13.1d_2023-08-22/LGPL Development Only (built 2023-08-22)
Comment