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

chore(DatePicker): updated controlled examples #9171

Merged
merged 2 commits into from
May 31, 2023

Conversation

thatblindgeye
Copy link
Contributor

What: Closes #9136

Additional issues:

@patternfly-build
Copy link
Contributor

patternfly-build commented May 23, 2023

Copy link
Contributor

@jenny-s51 jenny-s51 left a comment

Choose a reason for hiding this comment

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

This looks great @thatblindgeye and the updates work as expected. While testing I seem to have found a bug with the demos page and I'm curious if you're able to reproduce this - the page seems to jump to the wrong location when the calendar icon is clicked, though the location seems pretty inconsistent

date.picker.mov

@thatblindgeye
Copy link
Contributor Author

thatblindgeye commented May 23, 2023

@jenny-s51 I do get that bug as well. It looks like it's first getting positioned at the bottom of the page first:

image

Before getting positioned relative to the datepicker input:

image

(hate to pile onto poor Popper more but this might be another issue with Popper...)

@nicolethoen
Copy link
Contributor

is the Controlling the date picker calendar state example supposed to open/close the calendar when you click the button?

@thatblindgeye
Copy link
Contributor Author

thatblindgeye commented May 25, 2023

@nicolethoen based on the PR when the logic was first added yes, but it looks like it's been broken in v4 as well.

Looks like it might be a couple of things:

  • The useImperativeHandle toggleCalendar method has the setPopoverOpen inside a conditional that isn't ever true when clicking the button (was added in fix(DatePicker): enable DatePicker in a modal #7416 )
  • There's a setPopoverOpen(false) in Popover's shouldClose prop that is closing the popover, then it looks like the toggleCalendar is being called to open it again if we fix the above issue

@nicolethoen
Copy link
Contributor

Should we either remove the example for fix it? Maybe as a follow up issue? Seems to be revealing that there is a preexisting bug in the DatePicker. WDYT @tlabaj ?

@tlabaj
Copy link
Contributor

tlabaj commented May 30, 2023

@thatblindgeye @nicolethoen yes this issue existed in v4. @mcarrano had expresses that it would be nice to get this one fixed for the v5 release.

Comment on lines -192 to +193
toggleCalendar: (setOpen?: boolean, eventKey?: string) => {
if (eventKey === KeyTypes.Escape && popoverOpen && !selectOpen) {
setPopoverOpen((prev) => (setOpen !== undefined ? setOpen : !prev));
}
toggleCalendar: (setOpen?: boolean) => {
setPopoverOpen((prev) => (setOpen !== undefined ? setOpen : !prev));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolethoen @tlabaj Pushed an update that makes the example work as intended and added an integration test for the functionality.

I removed the eventKey param as it wasn't being used in the example when added, and it doesn't seem like it would be necessary any more? I tested the datepicker in modal demo and pressing Escape to close the datepicker didn't cause the issue of also closing the modal.

Comment on lines +235 to +239
if (popoverOpen) {
event.stopPropagation();
setPopoverOpen(false);
hideFunction();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevents the CalendarMonth from opening again when pressing the "Toggle" button to close it, and also allows clicking outside the CalendarMonth to close it.

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

The flashing calendar problem is so apparent in these examples. thats out of scope for this issue, and is reported in this issue and this issue.

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@tlabaj tlabaj merged commit 3b3db26 into patternfly:v5 May 31, 2023
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-code-editor@5.0.0-alpha.127
  • @patternfly/react-core@5.0.0-alpha.126
  • @patternfly/react-docs@6.0.0-alpha.136
  • demo-app-ts@5.0.0-alpha.110
  • @patternfly/react-integration@5.0.0-alpha.52
  • @patternfly/react-table@5.0.0-alpha.130

Thanks for your contribution! 🎉

nicolethoen pushed a commit to Kells512/patternfly-react that referenced this pull request Sep 1, 2023
* chore(DatePicker): updated controlled examples

* Updated logic for controlled example
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.

Bug - Calendar - misaligned button when validation text appears
7 participants