React-dates: Auto position when reached when reached end of parent

Created on 27 Nov 2018  路  7Comments  路  Source: airbnb/react-dates

It would be nice to have option to auto position the date selector when you react the end of the parent or the browser window.

feature request

Most helpful comment

This feels like a feature that should definitely be baked into the component.

All 7 comments

Hi @Rafi993 The date selector should auto-position according to the browser window (there's a responsive function that checks for the edge of the screen and shifts over the datepicker accordingly). Can you share a screenshot of the behavior you are seeing and the version of react-dates you are using?

2018-12-18-121040_1366x768

Version:
18.1.1

Ah, specifically from the bottom. It is responsive to the left and right edges of the screen, but does not scroll the page up when the picker is out of view.

@Rafi993 Are you suggesting that the picker automatically open up when the calendar is below the fold or that the viewport scroll up to show the calendar? I think for the latter, you could probably do right now by setting a ref on the SingleDatePicker component, checking where it is in relation to the viewport and updating the openDirection prop accordingly.

Internally there is not any code for that although I guess it is a possible addition. I am not certain that it is a high priority ask, but it is a potential addition.

Hi @majapw, I'm also interested in the picker automatically opening upward when there isn't enough space in the viewport for the calendar.

I think for the latter, you could probably do right now by setting a ref on the SingleDatePicker component, checking where it is in relation to the viewport and updating the openDirection prop accordingly.

Would I need to subscribe to scroll and resize events to achieve this or is there an easier way that you had in mind?

It would be nice if this feature was built in just like the left/right repositioning is. To do it properly requires some boilerplate for re-checking on scroll and resize and it would be great if that was just included in the existing check for left/right.

This feels like a feature that should definitely be baked into the component.

Just adding my +1 here.

Having to do some hacky workarounds due to lack of this feature.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yokomizor picture yokomizor  路  3Comments

aaronvanston picture aaronvanston  路  3Comments

jpollard-cs picture jpollard-cs  路  3Comments

augnustin picture augnustin  路  3Comments

ekohanyi picture ekohanyi  路  3Comments