Skip to content

UXE-1577: Migrate DateFilter to Via - #2118

Open
adamrasheed wants to merge 11 commits into
evergreen-ci:mainfrom
adamrasheed:UXE-1577
Open

adamrasheed wants to merge 11 commits into
evergreen-ci:mainfrom
adamrasheed:UXE-1577

Conversation

@adamrasheed

@adamrasheed adamrasheed commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

UXE-1577

Description

This PR moves DateFilter onto Via DatePicker. The picker follows Spruce's app locale (en-US) for date order, so it reads mm / dd / yyyy instead of LeafyGreen's YYYY-MM-DD. Weeks still start on Monday to match main.

Note: There are some LeafyGreen artifacts hanging around until UXE-1544. Also, the DatePicker input will now look smaller compared to the other inputs next to it until those inputs get migrated as well

Screenshots

Before After
Empty empty-before empty-after
With date with-date-before with-date-after
Calendar open calendar-open-before calendar-open-after

Testing

Checked DateFilter, Waterfall, and TaskHistory unit suites, check-types, eslint and prettier. Ran the waterfall date filter specs locally and manually checked as well.

Via's DatePicker returns CalendarDate values whose toString() is already
YYYY-MM-DD, so the manual UTC conversion goes away. That needs
@internationalized/date as a direct Spruce dependency. The lockfile only
adds the importer entry; a plain pnpm add also deduped @swc/helpers
across the tree, which is unrelated churn.

An empty or unparseable date param maps to null rather than undefined so
the picker stays controlled and clears when the filter resets on
pagination.

Via segments are spinbuttons rather than inputs, and Via doesn't
zero-pad the month, so the Playwright helpers type into the segments and
compare aria-valuenow. Month is typed last because it's the only segment
where a single keystroke commits, so the picker emits one complete date
instead of intermediate ones. The LeafyGreen helpers stay for the
SpruceForm date widgets until UXE-1544.
The LeafyGreen picker started weeks on Monday and Via defaults to the
locale's week start, which is Sunday for en-US. firstDayOfWeek keeps the
old behavior. The YYYY-MM-DD segment order still needs a date-only locale
in Via, tracked in UXE-1578.
@adamrasheed
adamrasheed marked this pull request as ready for review November 24, 2026 00:50
@adamrasheed
adamrasheed requested a review from a team as a code owner November 24, 2026 00:50
Comment thread apps/spruce/package.json Resolved
Comment thread apps/spruce/playwright/helpers/index.ts Outdated
if (expected[segment]) {
await expect(locator).toHaveAttribute(
"aria-valuenow",
String(Number(expected[segment])),

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.

Q: is it necessary to cast this if it's already a string?

Suggested change
String(Number(expected[segment])),
expected[segment],

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yep, aria-valuenow is unpadded so "02" has to become "2" before we compare. Number drops the zero and toHaveAttribute wants a string back

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.

I think we just update the calls then i.e.

await typeViaDatePickerDate(page, {
        year: "2025",
        month: "2",
        day: "28",
      });

await validateViaDatePickerDate(page, {
        year: "2025",
        month: "2",
        day: "28",
      });

with expected[segment] (no cast)

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.

It seems to clear the month and date inputs when I start typing in the year input, should that happen?

Screen.Recording.2026-11-24.at.12.01.00.AM.mov

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch, that shouldn't happen. we were dropping the partial year before it reached the URL and react-aria reset the field back to the empty value. it keeps its own draft value now so month and day stick around, fixed in 43f341a

- Import date utils from Via's Internationalized export and drop the
  direct @internationalized/date dependency
- Keep a local draft of the picker value so typing a partial year no
  longer wipes the month and day
- Give the picker a fixed width so it doesn't resize as segments fill in
- Make the Monday week-start test assert the weekday explicitly
@adamrasheed

Copy link
Copy Markdown
Collaborator Author

evergreen retry

@adamrasheed
adamrasheed requested a review from minnakt November 24, 2026 19:16

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

If we end up making a Via ticket, can we add TODO comments for the relevant sections?

Comment on lines +95 to +102
// The date segments are proportional text, so without a fixed width the field
// grows and shrinks as placeholders are replaced by digits. Each width fits the
// "mm / dd / yyyy" placeholder, the widest state. Flex rows like task history's
// controls would otherwise shrink it below that.
const StyledDatePicker = styled(DatePicker)<{ size?: Size }>`
width: ${({ size }) => (size === Size.Small ? "128px" : "140px")};
flex-shrink: 0;
`;

@minnakt minnakt Nov 24, 2026 •

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.

nit. I think we should be using css module styles, rather than styled components

Comment on lines +66 to +73
* Via's DatePicker only marks out-of-range dates invalid and still emits them,
* and it emits on every keystroke in the year segment (typing 2022 emits 0002,
* 0020, 0202, then 2022), so both have to be filtered before reaching the URL.
* @param date - the date the picker emitted
* @param min - the earliest allowed date, if any
* @param max - the latest allowed date
* @returns whether the date should be passed to onChange
*/

@minnakt minnakt Nov 24, 2026 •

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.

To me this seems kind of unfortunate, making the consumer do the calculation, as the LeafyGreen date picker only submitted when everything was filled. Is it possible for a fix be built into the Via component directly such that onChange only fires when a date is complete?

Comment on lines +31 to +40
// The picker keeps its own copy of the date so partial or out-of-range input
// stays on screen. Feeding it only the URL value would make react-aria reset
// the field, wiping the month and day while the year is still being typed.
const [draftDate, setDraftDate] =
useState<Internationalized.DateValue | null>(() => toCalendarDate(value));
const [syncedValue, setSyncedValue] = useState(value);
if (value !== syncedValue) {
setSyncedValue(value);
setDraftDate(toCalendarDate(value));
}

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.

I feel like fixing that in Via would help here as well

Comment thread apps/spruce/playwright/helpers/index.ts Outdated
if (expected[segment]) {
await expect(locator).toHaveAttribute(
"aria-valuenow",
String(Number(expected[segment])),

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.

I think we just update the calls then i.e.

await typeViaDatePickerDate(page, {
        year: "2025",
        month: "2",
        day: "28",
      });

await validateViaDatePickerDate(page, {
        year: "2025",
        month: "2",
        day: "28",
      });

with expected[segment] (no cast)

- Move the DateFilter width rules from a styled component to a CSS module
- Pass unpadded months to the Via date helpers and compare aria-valuenow
  directly instead of casting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants