aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrolls.java
blob: d69e5e20571365b0d08b9b6309902d3f24207bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.vaadin.tests.components.combobox;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.util.ItemDataProvider;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;

public class ComboBoxPopupWhenBodyScrolls extends AbstractReindeerTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        getPage().getStyles()
                .add("body.v-generated-body { overflow: auto;height:auto;}");
        getPage().getStyles().add(
                "body.v-generated-body .v-ui.v-scrollable{ overflow: visible;height:auto !important;}");
        ComboBox<String> cb = new ComboBox<>();
        cb.setDataProvider(new ItemDataProvider(10));

        Label spacer = new Label("foo");
        spacer.setHeight("2000px");
        addComponent(spacer);
        addComponent(cb);
        spacer = new Label("foo");
        spacer.setHeight("2000px");
        addComponent(spacer);
        // Chrome requires document.scrollTop (<body>)
        // Firefox + IE wants document.documentElement.scrollTop (<html>)
        getPage().getJavaScript().execute(
                "document.body.scrollTop=1800;document.documentElement.scrollTop=1800;");
    }
}