Repository navigation
UXE-1577: Migrate DateFilter to Via - #2118
adamrasheed wants to merge 11 commits into
Conversation
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.
…nd start weeks on Monday
| if (expected[segment]) { | ||
| await expect(locator).toHaveAttribute( | ||
| "aria-valuenow", | ||
| String(Number(expected[segment])), |
There was a problem hiding this comment.
Q: is it necessary to cast this if it's already a string?
| String(Number(expected[segment])), | |
| expected[segment], |
There was a problem hiding this comment.
yep, aria-valuenow is unpadded so "02" has to become "2" before we compare. Number drops the zero and toHaveAttribute wants a string back
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
evergreen retry |
minnakt
left a comment
There was a problem hiding this comment.
If we end up making a Via ticket, can we add TODO comments for the relevant sections?
| // 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; | ||
| `; |
There was a problem hiding this comment.
nit. I think we should be using css module styles, rather than styled components
| * 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 | ||
| */ |
There was a problem hiding this comment.
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?
| // 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)); | ||
| } |
There was a problem hiding this comment.
I feel like fixing that in Via would help here as well
| if (expected[segment]) { | ||
| await expect(locator).toHaveAttribute( | ||
| "aria-valuenow", | ||
| String(Number(expected[segment])), |
There was a problem hiding this comment.
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
UXE-1577
Description
This PR moves
DateFilteronto ViaDatePicker. 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
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.