Skip to content

[PB-6258] feat: add date modified filter to global search - #2071

Open
victor-ferro wants to merge 10 commits into
PB-6258-search-type-filterfrom
PB-6258-search-date-filter
Open

[PB-6258] feat: add date modified filter to global search#2071
victor-ferro wants to merge 10 commits into
PB-6258-search-type-filterfrom
PB-6258-search-date-filter

Conversation

@victor-ferro

Copy link
Copy Markdown
Contributor

Description

Part 3/4 of the PB-6258 stack. Adds the "Date modified" pill with single-choice presets (Today, Last 7/30 days, This/Last year) and a Specific date mode with After/Before inputs supporting open and closed ranges. Dates are typed (dd/mm/yyyy, strict) or picked in the new DateCalendar component; invalid or range-inverting entries are ignored. Includes the DropdownCloseObserver helper and i18n for the 8 locales.

Blocked by internxt/sdk#429 (see base PR #2069).

Related Issues

Relates to PB-6258 (JIRA).

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Manual browser testing: each preset issues the expected modifiedAfter/modifiedBefore ISO params; open ranges send a single param; each calendar disables days beyond the opposite bound; locale rendering verified in Spanish.

Additional Notes

Pre-existing bug found: the global dayjs locale set in i18n.service.ts falls back to English ('es-ES' is not normalized to 'es'). DateCalendar works around it with per-instance locales.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: d9a75b6
Status: ✅  Deploy successful!
Preview URL: https://8ec78ae6.drive-web.pages.dev
Branch Preview URL: https://pb-6258-search-date-filter.drive-web.pages.dev

View logs

…lter

# Conflicts:
#	src/views/Home/components/NavbarGlobalSearch.tsx
@victor-ferro
victor-ferro marked this pull request as ready for review July 29, 2026 14:42
Comment on lines +122 to +140
<div
role="none"
onMouseDown={(event) => event.preventDefault()}
onClick={(event) => event.preventDefault()}
>
<div className="flex flex-row items-center gap-2 px-4 py-2">
<RadioButton checked={isAnyDate} onClick={() => onSelectPreset('any')} />
<p className="text-gray-100">{translate('general.searchBar.filters.date.anyDate')}</p>
</div>
<div className="mx-4 border-t border-gray-10" />
{DATE_PRESET_ITEMS.map(({ id, labelKey }) => (
<div className="flex flex-row items-center gap-2 px-4 py-2" key={id}>
<RadioButton checked={preset === id} onClick={() => onSelectPreset(id)} />
<p className="text-gray-100">
{translate(`general.searchBar.filters.date.${labelKey}`, { year: presetYears[id] })}
</p>
</div>
))}
</div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would make the whole row clickable, not just the radio button

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!


const getCalendarLocale = (): string => {
const language = i18next.language ?? 'en';
return language.toLowerCase() === 'zh-tw' ? 'zh-tw' : language.split('-')[0].toLowerCase();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps we should document this, even if it’s just with a test, as it’s not immediately clear why this is the case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! Extracted getCalendarLocale so it takes the language as a parameter and added DateCalendar.test.ts documenting why zh-TW is the exception: traditional Chinese has its own dayjs locale, while every other regional variant — zh-CN included — collapses to its base one.

Comment on lines +46 to +47
const isDayDisabled = (day: Dayjs): boolean =>
Boolean((minDate && day.isBefore(minDate, 'day')) || (maxDate && day.isAfter(maxDate, 'day')));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’d say we need to check whether maxDate is later than today’s date, as we shouldn’t be able to filter by dates later than today, should we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@victor-ferro victor-ferro self-assigned this Jul 31, 2026
…lter

# Conflicts:
#	src/views/Home/components/SearchTypeFilter.tsx
…lter

# Conflicts:
#	src/views/Home/components/NavbarGlobalSearch.tsx
#	src/views/Home/components/SearchTypeFilter.tsx
The X that clears a date input was an icon with a mouse handler, so it
could not be reached or activated with the keyboard. It is now a button
that keeps preventing the input from blurring on mouse down while doing
the work on click, which also covers Enter and Space.

The calendar wrapper is marked as presentational: its mouse handler only
exists to keep focus in the input, which is what Sonar's S6848 flags.
@victor-ferro
victor-ferro requested a review from CandelR August 3, 2026 13:47
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

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.

2 participants