Skip to content

[EuiDatePicker] Fix display in overflow containers #3476

Closed

Description

@timroes

Currently EuiDatePicker does not work properly when places e.g. in a Modal where it doesn't have enough space. Instead it will just cause it's parent overflow: auto container to scroll:

screenshot-20200513-204914

It would be nice if it would be able to be used in these scenarios too.

Activity

  1. timroes commented on May 13, 2020

    @timroes
    ContributorAuthor

    Digging a bit in the code, it seems there are basically two ways this could potentially work:

    1. Use properties passed to popper (the library used by react-datepicker) to render the popover to somehow move it into an EuiPortal. I've tried this with code like:
    <EuiDatePicker
      selected={date}
      onChange={setDate}
      popperProps={{
        innerRef: (ref: HTMLElement) => {
          if (ref) {
            ref.style.zIndex = '9005';
          }
        },
      }}
      popperContainer={({ children }: { children: React.ReactElement }) => (
        <>{children && <EuiPortal>{children}</EuiPortal>}</>
      )}
    />

    It seems this basically works, but there are some issues, e.g. the stylings are missing, because the styles currently expect the popover to be a child of .euiDatepicker (very solveable problem). There are also more tricky problems, e.g. switching month in the calendar will now hide the calendar because of an exception. I think this might be due to outside click handlers on the popover being broken by the EuiPortal.

    1. Write an own datepicker wrapper, that will render the input box with an EuiPopover attached and just use react-datepicker with inline rendering inside the popover. This sounds to me like the more stable approach. It also seems react-datepicker doesn't have too much magic on the input control it renders (https://github.com/Hacker0x01/react-datepicker/blob/master/src/index.jsx#L823) that would need to be recreated.
  2. thompsongl commented on May 13, 2020

    @thompsongl
    Contributor

    I think Option 2 is the right approach. A similar method is used for EuiSuperDatePicker

  3. self-assigned this
    on Jul 6, 2020
  4. changed the title [-]Make EuiDatePicker work in overflow containers[/-] [+][EuiDatePicker] Fix display in overflow containers[/+] on Sep 20, 2020
  5. eko234 commented on Nov 3, 2021

    @eko234

    EuiSuperDatePicker works well in this regard, isn't it about time to fix this one?

  6. cchaos commented on Nov 3, 2021

    @cchaos
    Contributor

    Thanks for the ping. We're currently working on it, but it requires an almost complete refactor because of an outside dependency.

  7. eko234 commented on Nov 3, 2021

    @eko234

    Thanks for your answer, sorry for being rude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions