material icon indicating copy to clipboard operation
material copied to clipboard

datepicker repositions based on body size, not visible viewport (w/ scrolling)

Open maddy2308 opened this issue 11 years ago • 13 comments

screen shot 2015-09-22 at 1 15 30 pm Whenever I use the md-datepicker and if it is near the page margins it doesn't open properly. By not opening properly I mean it is not scrollable and it should by itself know where it needs to show the popup based on its space requirement. Just like the image showing it should have open on top and not keep opening in space where the user has no option to select the date

maddy2308 avatar Sep 22 '15 20:09 maddy2308

@maddy2308 Can you check whether this is happening with the latest fixes in place? You can use:

https://cdn.rawgit.com/angular/code.material.angularjs.org/master/HEAD/angular-material.js https://cdn.rawgit.com/angular/code.material.angularjs.org/master/HEAD/angular-material.css

jelbourn avatar Sep 22 '15 21:09 jelbourn

I just check it with the links that you provided above and it is still persistent. The datepicker continuously open and if it open near the end of page it just doesn't show the date picker element properly. Please find the screenshot attached. screen shot 2015-09-22 at 4 10 23 pm

maddy2308 avatar Sep 22 '15 23:09 maddy2308

Thinking more about it, pretty sure I know what the problem is.

jelbourn avatar Sep 22 '15 23:09 jelbourn

@jelbourn Also if it's near the edge(left/right) it get's clipped

You can see this on the docs if your window is narrowish https://material.angularjs.org/latest/#/demo/material.components.input image

Edit - never mind this is fixed in the latest master

epelc avatar Sep 23 '15 16:09 epelc

@jelbourn Tried the latest master, the fix works for me too. Thanks for fixing the issue. There's one small catch on the styling though - the calendar isn't truly center aligned for small screen, even the container for md-datepicker has layout-align="center" set. Please see below screenshot for reference.

image

Any chance this can be fixed along?

Edit

Trying to debug this. But strangely with inspector/firebug turned on, the issue seems to be gone (y-overflow is visible though, maybe the margin is covered up?)

image

Edit 2

One more thing to clarify - is md-datepicker designed to be responsive? Below is a comparison between Firefox and Chrome:

image

CLGitDev avatar Sep 24 '15 01:09 CLGitDev

@CLGitDev how did you produce that Chrome problem?

jelbourn avatar Sep 24 '15 22:09 jelbourn

@jelbourn Thanks for reverting. I tried again with the latest stable channel release of Chrome, the md-datepicker is now responsive. Looks like it's an issue specific to an older browser version.

I'm still seeing a margin on the right when the date picker is opened though.

CLGitDev avatar Sep 25 '15 05:09 CLGitDev

I was seeing this, now I get a bizzare spacing between all of the elements: image

*UPDATE: Seems I only get this issue on chrome.

pattyjogal avatar Sep 26 '15 03:09 pattyjogal

@pattyjogal It looks like your app might have some CSS that's affecting the calendar. Without a demo or some code it's impossible to tell.

Closing this now since the main problem (calendar being off-screen) should be resolved.

jelbourn avatar Sep 28 '15 15:09 jelbourn

similar issue still exists in Firefox when having multiple datepickers

51221308-799d-11e5-888d-33e57af61505

jsfiddle: http://jsfiddle.net/ps25aotj/

clicking the first pickers: everything ok scrolling down -> clicking on one of the pickers: above behavior appears

wasntme avatar Oct 23 '15 13:10 wasntme

The issue still seems to happen if the date picker is inside of a dialog. I tested with 1.0rc1, and this was the result:

screenshot from 2015-10-27 14 23 29

http://codepen.io/anon/pen/bVMwmy/

mkowalchuk avatar Oct 27 '15 21:10 mkowalchuk

We can Fix this issue by using MomentDateAdapter

  1. "@angular/material-moment-adapter": "6.3.2", in package.json

export const dateFormat = 'YYYY-MM-DD';

export const MOMENT_DATE_FORMATS: MatDateFormats = { parse: { dateInput: dateFormat }, display: { dateInput: dateFormat, monthYearLabel: 'MMMM Y', dateA11yLabel: 'LL', monthYearA11yLabel: 'MMMM Y' } };

@Component({ providers: [ {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, {provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS }, ] })

shrisowdhaman avatar Jul 12 '18 19:07 shrisowdhaman

@shrisowdhaman Please submit Angular Material questions here and issues here. This repo is for AngularJS Material.

Splaktar avatar Jul 12 '18 19:07 Splaktar