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

[EuiDatePickerRange] Respect endDateControl className prop #5329

Merged
merged 7 commits into from
Nov 1, 2021

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Oct 27, 2021

Summary

Use the className prop from the correct element (endDateControl)

Checklist

  • Check against all themes for compatibility in both light and dark modes
    - [ ] Checked in mobile
    - [ ] Checked in Chrome, Safari, Edge, and Firefox
    - [ ] Props have proper autodocs and playground toggles
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for any docs examples

  • Added or updated jest and cypress tests

  • Checked for breaking changes and labeled appropriately

  • Checked for accessibility including keyboard-only and screenreader modes

  • A changelog entry exists and is marked appropriately

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfection!! Great spot with the className fix as well!

@cee-chen
Copy link
Member

cee-chen commented Oct 27, 2021

@thompsongl Actually, sorry, 1 quick thought - do we want to add a small unit test for this? e.g.,

  it('uses individual EuiDatePicker props', () => {
    const component = render(
      <EuiDatePickerRange
        startDateControl={
          <EuiDatePicker popoverPlacement="left" className="hello" />
        }
        endDateControl={
          <EuiDatePicker popoverPlacement="left" className="world" />
        }
        {...requiredProps}
      />
    );

    expect(component).toMatchSnapshot();
  });

@thompsongl
Copy link
Contributor Author

Can't argue with adding a test that's copy-paste-able

@thompsongl thompsongl enabled auto-merge (squash) October 27, 2021 16:49
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5329/

@cchaos cchaos disabled auto-merge October 27, 2021 17:23
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end date popover isn't aligning the same way as before anymore.
Before
Screen Shot 2021-10-27 at 13 24 05 PM

After
Screen Shot 2021-10-27 at 13 23 21 PM

Please, please, review the rendered components before auto-merging

@thompsongl
Copy link
Contributor Author

Gah I did check the output locally, but apparently still had my override in place
Not quite sure how to handle this with how the default value comes through

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

Yeah sorry, I think I meant specifically we need to check the published CI build. There could be other local issues that don't show up until you view the that version.

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

Not quite sure how to handle this with how the default value comes through

I'm not sure we'd also want them to change the left/right position either. We may need to make this a custom prop asking for top/bottom position that affect both the start and end controls in one prop.

@thompsongl
Copy link
Contributor Author

thompsongl commented Oct 27, 2021

I'm not sure we'd also want them to change the left/right position either

It looks like changing left/right is what they want, not top/bottom: elastic/kibana#116471

Maybe there's a way to expand the isCustom prop to handle this. Like, have isCustom accept a configuration object that sets whether the 5-6 individual props are set during cloning:

<EuiDatePickerRange isCustom={{popoverPlacement: true}} /> // maybe `false` makes more sense?

Resulting in popoverPlacement not being added to the cloned element on L96. Behavior of isCustom without an object provided would remain unchanged

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

I've asked for clarification: elastic/kibana#116471 (comment)

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

Ugh, btw, none of this would be a problem if the popover was just one of ours inside of a portal.

@thompsongl
Copy link
Contributor Author

Ugh, btw, none of this would be a problem if the popover was just one of ours inside of a portal.

Ughhhh you're right

@cchaos
Copy link
Contributor

cchaos commented Oct 28, 2021

Found her a workaround. I think the ideal solution is to get ours rendering in a popover. We can do that by splitting the input from the calendar and putting in inline version in a popover. We do something similar in EuiSuperDatePicker. I started to explore the option in this codesandbox.

@thompsongl
Copy link
Contributor Author

thompsongl commented Oct 28, 2021

Thanks, @cchaos! I had the idea to use isCustom, but didn't put any code to it.
Really, it's probably time to start on #3901
The first step can be to move react-datepicker into src and swap out popper for EuiPopover, but I'll look at the level of effort required.

I'm going to scale this PR back to just the className fix and we can open a new PR with either your idea or a broader component reorg.

@thompsongl thompsongl changed the title [EuiDatePickerRange] Respect endDateControl popoverPlacement prop [EuiDatePickerRange] Respect endDateControl className prop Oct 28, 2021
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5329/

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Maybe update the PR description too?

@thompsongl thompsongl merged commit d134348 into elastic:master Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants