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

I want to change the position of the calendar #1246

Closed
m-morisaki opened this issue Jan 31, 2018 · 19 comments
Closed

I want to change the position of the calendar #1246

m-morisaki opened this issue Jan 31, 2018 · 19 comments
Labels

Comments

@m-morisaki
Copy link

m-morisaki commented Jan 31, 2018

The calendar is hidden on the smartphone.
Can you adjust the position?

2018-01-31 10 56 41

@postal286
Copy link

postal286 commented Jan 31, 2018

Have the same issue. Want to move it left depends on input position. Someone know how to do that ?).

This params will help you: 'auto', 'auto-left', 'auto-right', 'bottom', 'bottom-end', 'bottom-start', 'left', 'left-end', 'left-start', 'right', 'right-end', 'right-start', 'top', 'top-end', 'top-start'

Found params in src. You need to pass one of this values to popperPlacement props to the DatePicker component like that - <DatePicker popperPlacement="bottom-end" />.

Someone who knows how to contact with develop team tell them to update popperPlacement docs. It's not so clear to find this values. Thx.

@m-morisaki
Copy link
Author

I'm so grateful for that!

@benjaminkniaz
Copy link

Unfortunately, placement does not work for me, nor does it work in the official examples. I would expect placement to force the popper to appear on the bottom, etc.

@robhadfield
Copy link

Yep - as @benjaminkniaz says it doesn't force the position. if I say top-start I would expect to force that position even if it's near the screen edge.

@benjaminkniaz
Copy link

@robhadfield turns out you have to add a modifier to force the position. flip forces it not to flip even if the popper is going to be partially off-screen, and preventOverflow prevents it from covering the element you clicked, if again the popper detects the item will partially go off screen.

This is where I found the modifiers:
https://github.com/FezVrasta/popper.js/blob/master/docs/_includes/popper-documentation.md#modifiers..flip

<DatePicker
    selected={props.followup_complete_by_dt}
    onChange={props.handleDueDateChange}
    className="form-control"
    monthsShown={1}
    popperPlacement="bottom"
    popperModifiers={{
        flip: {
            behavior: ["bottom"] // don't allow it to flip to be above
        },
        preventOverflow: {
            enabled: false // tell it not to try to stay within the view (this prevents the popper from covering the element you clicked)
        },
        hide: {
            enabled: false // turn off since needs preventOverflow to be enabled
        }
    }}
/>

@robhadfield
Copy link

robhadfield commented Oct 1, 2018

Thanks a lot @benjaminkniaz , I'll give that a go. I ended up reverting to a dialog which really ruins the flow.

EDIT: @benjaminkniaz - worked perfectly, thanks!

@ryanlozon
Copy link

I'm still running into an issue where the popup appears off to the left. Any idea why it might be doing?
image
image

@robhadfield
Copy link

Here's the settings that work for me:

            <Picker
                showMonthDropdown
                showYearDropdown
                dropdownMode="select"
                dateFormat={ dateFormat }
                minDate={ isDate(minDate) ? moment(minDate) : null }
                maxDate={ isDate(maxDate) ? moment(maxDate) : null }
                placeholderText={ placeholder }
                selected={ date && isDate(date) ? moment(date) : initialDate }
                onChange={ onChange }
                disabled={ disabled }
                withPortal={ withPortal ? true : false }
                popperPlacement='bottom'
                popperModifiers={{
                    flip: {
                        behavior: ['bottom'] // don't allow it to flip to be above
                    },
                    preventOverflow: {
                        enabled: false // tell it not to try to stay within the view (this prevents the popper from covering the element you clicked)
                    },
                    hide: {
                        enabled: false // turn off since needs preventOverflow to be enabled
                    }
                }}
            />

@stale
Copy link

stale bot commented Aug 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@jacky-ew
Copy link

Screenshot 2020-04-23 at 17 09 07

Hi any possible solution to this issue? the datepicker is overlapped with the dates on calendar

@robhadfield
Copy link

@jacky-ew Looks like a z-index issue between the picker and Calendar, try dropping your calendar down to z-index:1 ?

@jacky-ew
Copy link

Hi i think its better to set datepicker popper to have z-index: 1, but cannot find props in the lib

@jacky-ew
Copy link

managed to solved it by adding z-index in div container instead, thank you @robhadfield

@robhadfield
Copy link

Difficult to advise without seeing the live code but glad you got it working 👍

@rrankawat
Copy link

Have the same issue. Want to move it left depends on input position. Someone know how to do that ?).

This params will help you: 'auto', 'auto-left', 'auto-right', 'bottom', 'bottom-end', 'bottom-start', 'left', 'left-end', 'left-start', 'right', 'right-end', 'right-start', 'top', 'top-end', 'top-start'

Found params in src. You need to pass one of this values to popperPlacement props to the DatePicker component like that - <DatePicker popperPlacement="bottom-end" />.

Someone who knows how to contact with develop team tell them to update popperPlacement docs. It's not so clear to find this values. Thx.
Awesome Man!!!

@savtwo
Copy link

savtwo commented Feb 21, 2021

Have the same issue. Want to move it left depends on input position. Someone know how to do that ?).

This params will help you: 'auto', 'auto-left', 'auto-right', 'bottom', 'bottom-end', 'bottom-start', 'left', 'left-end', 'left-start', 'right', 'right-end', 'right-start', 'top', 'top-end', 'top-start'

Found params in src. You need to pass one of this values to popperPlacement props to the DatePicker component like that - <DatePicker popperPlacement="bottom-end" />.

Someone who knows how to contact with develop team tell them to update popperPlacement docs. It's not so clear to find this values. Thx.

Wanted to add a little more detail to this. The react-datepicker library uses react-popper found here:

import { Manager, Reference, Popper, placements } from "react-popper";

react-popper is the wrapper for the popper library and the docs for the options are found here: https://popper.js.org/docs/v2/constructors/#options.

@infinitbility
Copy link

Added examples to show datepicker at down side

https://infinitbility.com/how-to-show-bottom-in-react-datepicker

@yannickNzali
Copy link

yannickNzali commented Aug 10, 2022

it works form me. The DatePicker's calendar is shown on top and is prevented to be shown bottom. I used the following code added to the :
<DatePicker
selected={ this.state.startDate }
onChange={ this.handleChange }
showTimeSelect
timeFormat="HH:mm"
timeIntervals={5}
timeCaption="time"
dateFormat="MMMM d,yyyy h:mm aa"
wrapperClassName="date-picker"
popperPlacement="top"
popperModifiers={{
flip: {
behavior: ["bottom"] // don't allow it to flip to be above
},
preventOverflow: {
enabled: false // tell it not to try to stay within the view (this prevents the popper from covering the element you clicked)
},
hide: {
enabled: false // turn off since needs preventOverflow to be enabled
}
}}
/>

@krystallopez
Copy link

@robhadfield turns out you have to add a modifier to force the position. flip forces it not to flip even if the popper is going to be partially off-screen, and preventOverflow prevents it from covering the element you clicked, if again the popper detects the item will partially go off screen.

This is where I found the modifiers: https://github.com/FezVrasta/popper.js/blob/master/docs/_includes/popper-documentation.md#modifiers..flip

<DatePicker
    selected={props.followup_complete_by_dt}
    onChange={props.handleDueDateChange}
    className="form-control"
    monthsShown={1}
    popperPlacement="bottom"
    popperModifiers={{
        flip: {
            behavior: ["bottom"] // don't allow it to flip to be above
        },
        preventOverflow: {
            enabled: false // tell it not to try to stay within the view (this prevents the popper from covering the element you clicked)
        },
        hide: {
            enabled: false // turn off since needs preventOverflow to be enabled
        }
    }}
/>

I am also running into an issue with changing the position of the datepicker, however, I tried this method as well and nothing changed. is there another dependency that needs to be installed into my application in order for the popper props to work?

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

No branches or pull requests