Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker does not detect orientation when container = body #392

Open
squinn opened this issue Oct 18, 2019 · 3 comments
Open

DatePicker does not detect orientation when container = body #392

squinn opened this issue Oct 18, 2019 · 3 comments

Comments

@squinn
Copy link

squinn commented Oct 18, 2019

Thanks again for this great project! We're starting to experiment with GMD a bit for a couple of potential projects, and are really enjoying the breadth and maturity of the GMD components.

I wanted to pass along a small issue that we noticed: the MaterialDatePicker component doesn't appear to correctly adjust it's orientation on a mobile device when the "container" option is set to "BODY".

E.g. this works fine:

<m:MaterialDatePicker placeholder="Pick Date:" fieldType="FILLED" container="SELF" detectOrientation="true"/>

But setting up a date picker like the following seems to then be stuck in portrait orientation:

<m:MaterialDatePicker placeholder="Pick Date:" fieldType="FILLED" container="BODY" detectOrientation="true"/>

@squinn
Copy link
Author

squinn commented Oct 18, 2019

For those that need it, here's a hack that can be used as a sort-of work around for this issue in the meantime:

public static void fixMaterialDatePickerOrientationDetection(MaterialDatePicker datePicker) {
    if(datePicker.getContainer() != DatePickerContainer.BODY) {
        return;
    }
    gwt.material.design.client.js.Window.addResizeHandler(resizeEvent -> {
        if (gwt.material.design.client.js.Window.matchMedia("(orientation: portrait)")) {
            datePicker.setOrientation(Orientation.PORTRAIT);
            $(".picker").removeClass("landscape");
        } else {
            datePicker.setOrientation(Orientation.LANDSCAPE);
            $(".picker").removeClass("portrait");
        }
    });
}

@kevzlou7979
Copy link
Contributor

Oh it might be the position: fixed was added to the date picker.

@kevzlou7979
Copy link
Contributor

Will try to check if theres a solid solution for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants