[PB-6258] feat: add date modified filter to global search - #2071
[PB-6258] feat: add date modified filter to global search#2071victor-ferro wants to merge 10 commits into
Conversation
Deploying drive-web with
|
| 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 |
3fe5d9f to
0d2bb8f
Compare
…lter # Conflicts: # src/views/Home/components/NavbarGlobalSearch.tsx
| <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> |
There was a problem hiding this comment.
I would make the whole row clickable, not just the radio button
|
|
||
| const getCalendarLocale = (): string => { | ||
| const language = i18next.language ?? 'en'; | ||
| return language.toLowerCase() === 'zh-tw' ? 'zh-tw' : language.split('-')[0].toLowerCase(); |
There was a problem hiding this comment.
Perhaps we should document this, even if it’s just with a test, as it’s not immediately clear why this is the case
There was a problem hiding this comment.
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.
| const isDayDisabled = (day: Dayjs): boolean => | ||
| Boolean((minDate && day.isBefore(minDate, 'day')) || (maxDate && day.isAfter(maxDate, 'day'))); |
There was a problem hiding this comment.
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?
…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.
… PB-6258-search-date-filter
|



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 newDateCalendarcomponent; invalid or range-inverting entries are ignored. Includes theDropdownCloseObserverhelper 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
Testing Process
Manual browser testing: each preset issues the expected
modifiedAfter/modifiedBeforeISO 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.tsfalls back to English ('es-ES'is not normalized to'es').DateCalendarworks around it with per-instance locales.