forked from vaadin/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to PopupView and LayoutManager size calculations during transform.
- ComputedStyle is slower but more reliable than using getBoundingClientRect, which does not work as expected if a transform has been applied to the element or one of its parents. This is a problem e.g. with PopupView, where getBoundingClientRect will return 0 for all the popup content sizes while the opening animation is active. ComputedStyle ignores the transform and returns the expected value. - On occasion PopupView's popup contents are measured too early and any calculations that rely on those measurements get erroneous results. Check at the end of the layout whether the measuring succeeded, and re-calculate if it did not. - If layout is still running but actual layout phases are over, leave elements that need measuring for the next round. - If there are pending layouts, trigger them immediately after previous layout round finishes, rather than hoping that the timer will trigger eventually. Allow for one millisecond delay in case there are other pending changes waiting for an opportunity to get processed first. - If the timer is run while layout is still running, do nothing and wait for the timer to get triggered again when the layout round is finished. - Manual test, problem isn't reproducible by TestBench. Fixes: vaadin#11187
- Loading branch information
Showing
8 changed files
with
145 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
.../src/main/java/com/vaadin/tests/components/popupview/PopupViewContentWithExpandRatio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.vaadin.tests.components.popupview; | ||
|
||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.tests.util.LoremIpsum; | ||
import com.vaadin.ui.Button; | ||
import com.vaadin.ui.JavaScript; | ||
import com.vaadin.ui.Label; | ||
import com.vaadin.ui.PopupView; | ||
import com.vaadin.ui.VerticalLayout; | ||
|
||
public class PopupViewContentWithExpandRatio extends AbstractTestUI { | ||
private PopupView popup; | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
popup = new PopupView("Open popup", createPopupContent()); | ||
popup.setHideOnMouseOut(false); | ||
popup.setPopupVisible(false); | ||
addComponent(popup); | ||
} | ||
|
||
private VerticalLayout createPopupContent() { | ||
Label label = new Label( | ||
"Placeholder content that should take up most of the available space"); | ||
label.setValue(LoremIpsum.get(56)); | ||
label.setSizeFull(); | ||
label.setId("label"); | ||
|
||
Button refreshBtn = new Button("Force layout", e -> { | ||
JavaScript.eval("vaadin.forceLayout()"); | ||
}); | ||
refreshBtn.setId("refresh"); | ||
|
||
Button submitBtn = new Button("Close popup"); | ||
submitBtn.addClickListener(clickEvent -> { | ||
popup.setPopupVisible(false); | ||
}); | ||
submitBtn.setId("close"); | ||
|
||
VerticalLayout content = new VerticalLayout(); | ||
content.setHeight("300px"); | ||
content.setSpacing(true); | ||
content.setMargin(true); | ||
|
||
content.addComponent(label); | ||
content.addComponent(refreshBtn); | ||
content.addComponent(submitBtn); | ||
content.setExpandRatio(label, 2.0f); | ||
return content; | ||
} | ||
|
||
@Override | ||
protected Integer getTicketNumber() { | ||
return 11187; | ||
} | ||
|
||
@Override | ||
protected String getTestDescription() { | ||
return "Expand ratio shouldn't cause contents to overflow " | ||
+ "from popup view. The popup should be opened at least " | ||
+ "20 times without SuperDevMode or TestBench or other " | ||
+ "configurations that might slow down the processing."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters