fix: Firefox datetime-local calendar picker not applying date filter#4445
fix: Firefox datetime-local calendar picker not applying date filter#4445balanza wants to merge 1 commit into
Conversation
|
The preview environment for this pull request is ready at 4445.prenv.trento.suse.com. |
antgamdia
left a comment
There was a problem hiding this comment.
Nice! It's a pity the selector does not work... while the solution is not perfect, it is ok-ish enough to work around the issue. Would it be possible to add a unit test case covering this?
c7d4648 to
61fe604
Compare
antgamdia
left a comment
There was a problem hiding this comment.
Thanks! Triggering also our friend copilot for a second pair of eyes and +1ing to unblock it.
| expect(mockOnChange).toHaveBeenCalledWith(['custom', expectedDate]); | ||
| }); | ||
|
|
||
| it('leaves the custom input empty until focused, then fills the current time so a date-only calendar pick still applies the filter (Firefox)', async () => { |
There was a problem hiding this comment.
Pull request overview
This PR targets a Firefox-specific quirk with <input type="datetime-local"> in the Activity Log date filters, aiming to ensure that picking a date via the native calendar reliably results in a valid filter value and triggers the expected onChange behavior.
Changes:
- Updates
DateFilter’s datetime-local input behavior to better handle Firefox interactions by managing an internal draft value and filling time on focus. - Adjusts existing tests to focus/clear the datetime-local input before typing, and adds a new Firefox-focused DateFilter test case.
- Keeps Activity Log and composed filter test flows aligned with the new input interaction requirements.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| assets/js/pages/ActivityLogPage/ActivityLogPage.test.jsx | Adds focus/clear steps before typing into datetime-local to make test interaction more realistic/stable. |
| assets/js/common/DateFilter/DateFilter.test.jsx | Updates typing tests and adds a new test covering Firefox-focused behavior around focus-filling time. |
| assets/js/common/DateFilter/DateFilter.jsx | Introduces draft state + onFocus time fill behavior for the datetime-local input. |
| assets/js/common/ComposedFilter/ComposedFilter.test.jsx | Adds focus/clear steps before typing into datetime-local to match updated interaction expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| value={value ? dateToValue(value) : draft} | ||
| onFocus={fillTimeOnFocus} | ||
| onChange={(e) => { | ||
| setDraft(e.target.value); | ||
| const utcDate = dateTimeLocalToUtcDate(e.target.value); | ||
|
|
| ) | ||
| ); | ||
| }; | ||
|
|
Problem
When using the Activity Log date filters (
from_date/to_date) in Firefox, selecting a date from the native calendar picker does not apply the filter. The date appears chosen in the picker UI but the filter never triggers.This is a known Firefox quirk with
<input type="datetime-local">: when the calendar picker is used to select a date, Firefox may only set the date part (YYYY-MM-DD) without the time component, leaving the input value incomplete. This caused:dateTimeLocalToUtcDatereturnednullearly, the date change was silently dropped.YYYY-MM-DD(missingT00:00):new Date("2024-01-15")parsed as midnight UTC, then.getHours()/.getMinutes()returned values in the browser's local timezone, producing an incorrect UTC timestamp when converted to the user's profile timezone.Solution
In
DateFilter.jsx, before parsing thedatetime-localvalue, detect when the value is a date-only string (YYYY-MM-DDwithout time) and normalize it toYYYY-MM-DDT00:00. This ensures:datetime-localformatnew Date("2024-01-15T00:00")correctly interprets midnight in the browser's timezonegetHours()/getMinutes()return0/0, correctly mapping to midnight (start of day) in the user's profile timezoneRelated
Closes the Firefox date selection bug described in the issue (date selection with the calendar in Activity Log filters don't work in Firefox).
Testing