appendToBody: calendar position is wrong, when scroll body.
See original GitHub issuereact-dates version react-dates@20.1.0
Describe the bug Calendar position is wrong, when scroll body.
Source code
export default function getDetachedContainerStyles(openDirection, anchorDirection, referenceEl) {
const referenceRect = referenceEl.getBoundingClientRect();
let offsetX = referenceRect.left;
let offsetY = referenceRect.top;
if (openDirection === OPEN_UP) {
offsetY = -(window.innerHeight - referenceRect.bottom);
}
if (anchorDirection === ANCHOR_RIGHT) {
offsetX = -(window.innerWidth - referenceRect.right);
}
return {
transform: `translate3d(${Math.round(offsetX)}px, ${Math.round(offsetY)}px, 0)`,
};
}
picture
modify DOM make body scroll calendar position is wrong
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
appendToBody: calendar position is wrong, when scroll body ...
Because Calendar DOM use transform. So, Calendar position is wrong, when scroll body out of window.
Read more >Bootstrap Datepicker appearing at incorrect location in a modal
I have a button on a page that calls a modal having datepicker. If this button is at top (I don't have to...
Read more >Angular directives for Bootstrap - AngularUI
datepicker-append-to-body $ C (Default: false , Config: appendToBody ) ... popup will attempt to position where it fits in the closest scrollable ancestor....
Read more >Element size and scrolling - The Modern JavaScript Tutorial
For elements with position:fixed . offsetWidth/Height. Now let's move on to the element itself. These two properties are the simplest ones. They ...
Read more >DatePicker not changing position when scrolling - Telerik
body. In order to achieve your goal you can modify telerik.datapicker.js file like so: $calendar ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We gave up on react-dates in favor of
react-datepicker
(uses popper for its positioning).I’m having a similar issue. We offset the
top
position of thebody
element when opening a modal to freeze the page in place, but this means any datepicker withappendToBody
set is unaware of the body offset and is positioned incorrectly if you have scrolled at all before opening the modal.If you set the appended datepicker to
position: fixed
it actually works properly even if the page has been scrolled before opening the modal, but this has to be done in JS because react-dates doesn’t let us add a custom class to the generated elements.Not only that, I tried to set
disableScroll
to false, and it still forcesoverflow-y: hidden
to the page, so that attribute appears to not work?Very frustrating all around.