-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38962 - Update DateTimePicker to pf5 #10802
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the DateTimePicker, DatePicker, and TimePicker components by migrating from custom implementations to PatternFly 5 native components. The changes simplify the codebase significantly by removing numerous custom date/time handling components and replacing them with PF5's built-in functionality.
Key Changes
- Replaced custom date/time pickers with PatternFly 5 components (CalendarMonth, DatePicker, TimePicker)
- Migrated test suite from Enzyme to React Testing Library
- Removed over 1000 lines of custom date handling logic and components
- Added helper functions for date/time formatting
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dateTimeHelpers.js | New utility file with formatTime and formatDate helper functions |
| DateTimePicker.js | Converted to functional component using PF5 CalendarMonth and custom TimePicker |
| DatePicker.js | Simplified to wrap PF5 DatePicker component |
| TimePicker.js | Simplified to wrap PF5 TimePicker component |
| *.test.js files | Migrated from Enzyme to React Testing Library |
| date-time-picker.scss | Removed legacy styles, added minimal wrapper styles |
| DateComponents/* | Deleted custom date picker components (MonthView, YearView, DecadeView, etc.) |
| TimeComponents/* | Deleted custom time picker components |
| form_helper.rb | Added time_local_f helper method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateTimePicker.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateTimePicker.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateTimePicker.js
Outdated
Show resolved
Hide resolved
cbd93fe to
e5e958e
Compare
|
Fixed review comments, added isFutureOnly prop, fixed the extra 0 bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 54 out of 54 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateTimePicker.js
Show resolved
Hide resolved
| } | ||
| }; | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [valueDate, valueTime, value, required, isFutureOnly]); |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interval cleanup is missing onChange in the dependency array but uses it. The useEffect at line 43 uses the onChange callback (line 54) but doesn't include it in the dependency array (line 70). This violates the rules of hooks and could lead to calling a stale onChange function. Either add onChange to the dependency array or wrap it with useCallback in the parent component.
e5e958e to
093f82f
Compare
| const [valueDate, setValueDate] = useState(formatDate(initialValue)); | ||
| const [valueTime, setValueTime] = useState(formatTime(initialValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mean to block the review here and certainly not block, but I notice you store a formatted date in the store. Isn't it possible to store a Date object instead of a string? My main concern is that you can't deal with timezones this way which can be important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example? formatDate and formatTime use a New Date( object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I read the flow you take initialValue (which could be timezone aware) deconstruct that into simple strings for both date and time. Then reuse that into a string value. Could the TextInput itself be fed a Date instance with a format function? Effectively removing the formatDate and formatTime helpers.
Out of my interest I tried to read up on what HTML can do. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/datetime-local uses the value 2018-06-12T19:30 which is the ISO 8601 format. So perhaps pass that around as much as possible?
Then I don't know what PatternFly does, but I noticed https://www.patternfly.org/components/forms/text-input/ supports datetime-local too (instead of text). Is that only in PF6?
And this is still for me to understand how we deal with dates, not a formal review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will say that from my tests by editing the field with a different timezone all worked as expected, and the server respected the correct timezone (set the generate report to 3 mins in the future and it only downloaded 3 mins later)
093f82f to
93e63e2
Compare
Bug in PF patternfly/patternfly-react#6569
Fixed
I based my work on the PF design, and it doesnt disappear on click away as well |
strangely that second example there with Date and time range picker doesn't have this problem, not sure why |
@pondrejk |
|
todo: editing the time when date is empty should populate the date |
93e63e2 to
870cfa6
Compare
|
Fixed: calendar close on clickout side and on date select, selecting a time when there is no date sets the date to today. |
| </InputGroupItem> | ||
| <InputGroupItem className="date-picker-input-item"> | ||
| <TimePicker | ||
| value={valueTime} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, maybe some ouiaId here as well?, because right now the time picker input has id=""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no ouiaId prop for timepicker, instead I gave it
id={`${id}-time-picker`}
870cfa6 to
28107f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack from the functional side, UI works nice, the time offset is honored when creating a report. Also positive PRT result in SatelliteQE/robottelo#20541 proves the automation is not affected and the tested scenario still works
ofedoren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @MariaAga and @pondrejk !
Just for future reference sake:
- Why is the time shown twice? In patternfly docs there are examples where it's either shown together or completely separate. We currently have it mixed.
- The old UI had a
Todaybutton, but it doesn't seem to be present now. Does clear button do it instead?
I didnt like that the PF docs created a new time selector which was just a dropdown with times, and I wanted to reuse existing components, so I put the timepicker component as it is.
No, clear only removes the date, PF example just have buttons outside the date picker to reset and clear the date https://v5-archive.patternfly.org/components/date-and-time/date-picker#controlled-required |
Honestly, I'm not sure if this button is being used by the users, but at least it would feel the same since we already have such button. |







The original task states:
Deprecate the 3 components: TimePicker, DatePicker and DateTimePicker
Investigate where the components are used so we can plan the work to replace their usage
But the components are used in erb forms, so they should still be wrapped.
I only found them being used in the generate report erb. but in the future we might need to reuse the datetime picker, which PF doesnt supply directly.
foreman_remote_job_execution uses a different type of a datetime picker, thats because in there users can select a date and a time separately, but in some form, it might be necessary to have the date and time in the same text field, like in the generate page.