question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

appendToBody: calendar position is wrong, when scroll body.

See original GitHub issue

react-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

image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

3reactions
koraccommented, Jun 26, 2019

We gave up on react-dates in favor of react-datepicker (uses popper for its positioning).

1reaction
mattaningramcommented, Jun 19, 2019

I’m having a similar issue. We offset the top position of the body element when opening a modal to freeze the page in place, but this means any datepicker with appendToBody 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 forces overflow-y: hidden to the page, so that attribute appears to not work?

Very frustrating all around.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found