Skip to content

fix: Firefox datetime-local calendar picker not applying date filter#4445

Open
balanza wants to merge 1 commit into
mainfrom
fix-firefox-date
Open

fix: Firefox datetime-local calendar picker not applying date filter#4445
balanza wants to merge 1 commit into
mainfrom
fix-firefox-date

Conversation

@balanza

@balanza balanza commented Jul 2, 2026

Copy link
Copy Markdown
Member

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:

  1. Value is empty (input in invalid state — no time part): dateTimeLocalToUtcDate returned null early, the date change was silently dropped.
  2. Value is just YYYY-MM-DD (missing T00: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 the datetime-local value, detect when the value is a date-only string (YYYY-MM-DD without time) and normalize it to YYYY-MM-DDT00:00. This ensures:

  • The value is always in a valid datetime-local format
  • new Date("2024-01-15T00:00") correctly interprets midnight in the browser's timezone
  • getHours()/getMinutes() return 0/0, correctly mapping to midnight (start of day) in the user's profile timezone

Related

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

  • ✅ All 16 DateFilter tests pass
  • ✅ All 53 ActivityLogPage tests pass
  • ✅ All 14 timezone lib tests pass
  • ✅ All 5 ComposedFilter tests pass

@balanza balanza added the env Create an ephimeral environment for the pr branch label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

The preview environment for this pull request is ready at 4445.prenv.trento.suse.com.

@antgamdia antgamdia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@balanza balanza marked this pull request as draft July 2, 2026 08:25
@balanza balanza force-pushed the fix-firefox-date branch 2 times, most recently from c7d4648 to 61fe604 Compare July 2, 2026 14:34
@balanza balanza marked this pull request as ready for review July 2, 2026 14:35
@balanza balanza force-pushed the fix-firefox-date branch from 61fe604 to 1ab1a9d Compare July 2, 2026 14:41
@balanza balanza force-pushed the fix-firefox-date branch from 1ab1a9d to 7fbb2f9 Compare July 2, 2026 15:44

@antgamdia antgamdia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment on lines +150 to 155
value={value ? dateToValue(value) : draft}
onFocus={fillTimeOnFocus}
onChange={(e) => {
setDraft(e.target.value);
const utcDate = dateTimeLocalToUtcDate(e.target.value);

)
);
};

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

Labels

env Create an ephimeral environment for the pr branch

Development

Successfully merging this pull request may close these issues.

3 participants