Browse Source

Fix Window layout when resizing (#10830)

Fixes #10652
tags/8.5.0.alpha1
Anna Koskinen 6 years ago
parent
commit
1d6002baf9

+ 1
- 1
client/src/main/java/com/vaadin/client/WidgetUtil.java View File

final int scrollleft = elem.getScrollLeft(); final int scrollleft = elem.getScrollLeft();
elem.getStyle().setProperty("overflow", "hidden"); elem.getStyle().setProperty("overflow", "hidden");


Scheduler.get().scheduleDeferred(() -> {
Scheduler.get().scheduleFinally(() -> {
// Dough, Safari scroll auto means actually just a moped // Dough, Safari scroll auto means actually just a moped
elem.getStyle().setProperty("overflow", originalOverflow); elem.getStyle().setProperty("overflow", originalOverflow);
if (!originalOverflowX.isEmpty()) { if (!originalOverflowX.isEmpty()) {

+ 10
- 0
client/src/main/java/com/vaadin/client/ui/VWindow.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.HasComponentsConnector;
import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.WidgetUtil; import com.vaadin.client.WidgetUtil;
import com.vaadin.client.debug.internal.VDebugWindow; import com.vaadin.client.debug.internal.VDebugWindow;
*/ */
WidgetUtil WidgetUtil
.runWebkitOverflowAutoFix(contents.getFirstChildElement()); .runWebkitOverflowAutoFix(contents.getFirstChildElement());
Scheduler.get().scheduleFinally(() -> {
List<ComponentConnector> childComponents = ((HasComponentsConnector) ConnectorMap
.get(client).getConnector(this)).getChildComponents();
if (!childComponents.isEmpty()) {
LayoutManager layoutManager = getLayoutManager();
layoutManager.setNeedsMeasure(childComponents.get(0));
layoutManager.layoutNow();
}
});
} }
} }



+ 41
- 0
uitest/src/main/java/com/vaadin/tests/components/window/WindowTwinColSelect.java View File

package com.vaadin.tests.components.window;

import java.util.Arrays;

import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.TwinColSelect;
import com.vaadin.ui.Window;

@Widgetset("com.vaadin.DefaultWidgetSet")
public class WindowTwinColSelect extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final TwinColSelect<String> testScroll = new TwinColSelect<>();
testScroll.setItems(Arrays.asList("Option1", "Option2"));
testScroll.setRows(10);
testScroll.setSizeFull();
testScroll.setHeightUndefined();

Window window = new Window();
window.setHeight("200px");
window.setWidth("400px");
window.setModal(true);
window.setContent(testScroll);
addWindow(window);
window.center();
}

@Override
protected String getTestDescription() {
return "Scroll bar shouldn't interfere with how "
+ "full-size TwinColSelect contents are displayed.";
}

@Override
protected Integer getTicketNumber() {
return 10652;
}
}

+ 9
- 0
uitest/src/test/java/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java View File

import static com.vaadin.tests.components.window.ComboboxScrollableWindow.COMBOBOX_ID; import static com.vaadin.tests.components.window.ComboboxScrollableWindow.COMBOBOX_ID;
import static com.vaadin.tests.components.window.ComboboxScrollableWindow.WINDOW_ID; import static com.vaadin.tests.components.window.ComboboxScrollableWindow.WINDOW_ID;


import java.util.List;

import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;


import com.vaadin.testbench.By; import com.vaadin.testbench.By;
import com.vaadin.testbench.commands.TestBenchElementCommands; import com.vaadin.testbench.commands.TestBenchElementCommands;
*/ */
public class ComboboxScrollableWindowTest extends MultiBrowserTest { public class ComboboxScrollableWindowTest extends MultiBrowserTest {


@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Fix to #10652 broke this for PhantomJS
return getBrowsersExcludingPhantomJS();
}

@Test @Test
public void testWindowScrollbars() throws Exception { public void testWindowScrollbars() throws Exception {
openTestURL(); openTestURL();

+ 47
- 0
uitest/src/test/java/com/vaadin/tests/components/window/WindowTwinColSelectTest.java View File

package com.vaadin.tests.components.window;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.TwinColSelectElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class WindowTwinColSelectTest extends MultiBrowserTest {

@Test
public void testBothVisibleInitially() {
openTestURL();
TwinColSelectElement twinColSelect = $(TwinColSelectElement.class)
.first();
WebElement optionsElement = twinColSelect.getOptionsElement();
WebElement selectionsElement = twinColSelect.getSelectionsElement();
assertTrue(optionsElement.isDisplayed());
assertTrue(selectionsElement.isDisplayed());
assertThat(selectionsElement.getLocation().getY(),
is(optionsElement.getLocation().getY()));
}

@Test
public void testBothVisibleAfterResize() {
openTestURL();
waitForElementPresent(By.className("v-window-resizebox"));
TwinColSelectElement twinColSelect = $(TwinColSelectElement.class)
.first();
new Actions(getDriver())
.moveToElement(findElement(By.className("v-window-resizebox")))
.clickAndHold().moveByOffset(-30, -30).release().build()
.perform();
WebElement optionsElement = twinColSelect.getOptionsElement();
WebElement selectionsElement = twinColSelect.getSelectionsElement();
assertTrue(optionsElement.isDisplayed());
assertTrue(selectionsElement.isDisplayed());
assertThat(selectionsElement.getLocation().getY(),
is(optionsElement.getLocation().getY()));
}
}

Loading…
Cancel
Save