Skip to content

Conversation

@shaneeza
Copy link
Collaborator

@shaneeza shaneeza commented Nov 6, 2025

✍️ Proposed changes

This PR is the third PR in a series of three PRs that add the new InputBox package and integrate it into the existing DatePicker package:

  1. [LG-5504] feat(input-box): add InputSegment  #3293
  2. [LG-5504] feat(input-box): add InputBox #3285
  3. This PR

This PR refactors the date-picker package to leverage the new @leafygreen-ui/input-box component instead of maintaining custom input segment implementations. This migration significantly simplifies the codebase by removing redundant logic and utilities, while maintaining the same functionality through the shared input-box component.

Key changes include:

  • Replaced custom DateInputSegment implementation with InputSegment from @leafygreen-ui/input-box
  • Removed custom keyboard navigation, value formatting, and validation logic, now handled by input-box
  • Deleted obsolete utility functions and their tests (1,319 deletions, 146 insertions)
  • Simplified DatePickerInput and DateInputBox components

🎟️ Jira ticket: LG-5504

✅ Checklist

  • I have added stories/tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have run pnpm changeset and documented my changes

🧪 How to test changes

  1. Navigate to the date-picker component in Storybook
  2. Test all keyboard navigation (arrow keys, tab, backspace) within date input segments
  3. Verify that date input segments behave identically to the previous implementation
  4. Test edge cases: min/max date constraints, placeholder behavior, and value formatting
  5. Ensure all existing date-picker tests pass

… improved type handling and event management
…with improved type handling and segment management
… new props for step handling and rollover management
…icker components for improved segment management and type handling
…nce segment validation logic for improved date handling
…tSegment and InputBox tests for better coverage
…ent components by introducing utility functions
…gment components for improved clarity and documentation
…ting getValueFormatter to accept segment-specific character counts
… for year segment and enhance validation logic
… tests for InputBox and InputSegment components
@shaneeza shaneeza marked this pull request as draft November 17, 2025 14:33
…n testutils for enhanced testing capabilities
…nputBox stories with date and time segment examples
…ygreen-ui into LG-5504/input-box-in-date-picker-3
…elated references to charsCount for consistency
…ate DateInputBoxProviderProps to extend PropsWithChildren for better type handling
…-digit year value in custom validation for date segments
…tead of charsPerSegment across components and tests for consistency
@shaneeza shaneeza marked this pull request as ready for review November 19, 2025 15:55
@shaneeza shaneeza requested a review from stephl3 November 19, 2025 15:55
Comment on lines 99 to 112
<InputBox
ref={fwdRef}
segmentRefs={segmentRefs}
segmentEnum={DateSegment}
formatParts={formatParts}
segments={segments}
setSegment={setSegment}
disabled={disabled}
segmentRules={dateSegmentRules}
onSegmentChange={onSegmentChange}
labelledBy={labelledBy}
segmentComponent={DateInputSegment}
{...rest}
/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

re: previous comment on pass-through props, segmentRefs, onSegmentChange, and labelledBy look like they can also be passed through. I think this has the benefit of making it clearer which props are provided from DatePicker context or derived by other means

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, it looks like className is no longer being considered. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whoops, I missed these. Thanks.

@shaneeza shaneeza requested a review from stephl3 November 19, 2025 19:35
…ableSnapshot in DatePicker stories and pass size prop to InputBox
value,
}: PropsWithChildren<DateInputBoxProviderProps>) => {
return (
<DateInputBoxContext.Provider value={{ value }}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: it's a bit confusing to have the DateInputBoxProvider prop named value that's different from the DateInputBoxContext.Provider value prop

Comment on lines +37 to +43
const {
autoComplete: autoCompleteProp,
min: minContextProp,
max: maxContextProp,
} = useSharedDatePickerContext();

const { value: dateValue } = useDateInputBoxContext();
Copy link
Collaborator

Choose a reason for hiding this comment

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

My intuition says the dateValue should be on the useSharedDatePickerContext. Is it just not needed until the DateInputBoxContext?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the date value isn't stored in the SharedDatePickerProvider because this provider was built with the date range picker in mind. I believe because of the range picker, there can be multiple DateInputBox components within a SharedDatePickerProvider, and each component needs its own separate value, which DateInputSegment relies on. So storing a single value in the shared provider might not be correct.

Does that sound familiar? If any of that is incorrect, then I can add the value to the shared provider.

): boolean => {
return Object.entries(segments).every(([segment, value]) =>
isExplicitSegmentValue(segment as DateSegment, value),
isExplicitSegmentValue({ segment: segment as DateSegment, value }),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is segment not automatically typed as DateSegment here?

Base automatically changed from LG-5504/input-box-component to shaneeza/time-picker-integration November 20, 2025 02:05
@github-actions
Copy link
Contributor

Coverage after merging LG-5504/input-box-in-date-picker-3 into shaneeza/time-picker-integration will be

78.87%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
charts/chart-card/src/ChartCard
   ChartCardContext.tsx60%100%50%66.67%25
charts/colors/src
   colors.ts0%100%100%0%25, 44, 5
charts/core/src
   constants.ts50%100%0%66.67%13
charts/core/src/Axis
   Axis.ts0%0%0%0%15, 19, 21, 23, 23, 45, 45, 61
   XAxis.tsx0%0%0%0%15, 19, 31, 34, 34, 58–60, 62–63, 63, 63, 65, 67, 71, 78
   YAxis.tsx0%0%0%0%15, 19, 30, 33, 33, 57–59, 61–62, 62, 62, 64, 66, 70, 77
charts/core/src/Chart
   Chart.tsx81.25%66.67%100%100%58, 64, 95
charts/core/src/Chart/config
   getDefaultChartOptions.ts100%100%100%100%
charts/core/src/Chart/hooks
   useChart.ts77.01%82.14%76.92%73.91%118, 118, 118–119, 123, 123, 123–125, 128, 132, 136–137, 139–140, 92, 98
   useTooltipVisibility.ts41.56%25%40%49.44%109–110, 120, 131, 133, 133, 133, 133, 133–135, 145, 145, 145–146, 149, 149, 149–151, 153–154, 166, 166, 166–167, 170, 170, 170–171, 171, 174–176, 190, 190, 190–191, 194, 194, 194–195, 195, 198–199, 224, 224, 228–229, 231–234, 276, 280–283, 46, 55, 55, 55, 55, 55–56, 59–60, 78, 78, 78–79, 87, 91–93
charts/core/src/ChartContext
   ChartContext.tsx83.33%50%100%87.50%21–22
charts/core/src/ChartHeader
   ChartHeader.tsx100%100%100%100%
charts/core/src/ChartTooltip
   ChartTooltip.tsx0%0%0%0%100–101, 105–106, 106, 106, 108, 111, 111, 115, 115, 115, 143, 143, 147–148, 163, 22, 35–36, 38, 40, 64, 70–71, 71, 71, 77, 82–83, 87, 87, 87–88, 92, 97–98
   utils.ts100%100%100%100%
charts/core/src/ChartTooltip/CustomTooltip
   CustomTooltip.testUtils.ts0%100%100%0%3
   CustomTooltip.tsx78.26%66.67%100%88.89%46–47, 54, 60, 69
charts/core/src/ChartTooltip/CustomTooltip/SeriesList
   SeriesList.tsx90.91%83.33%100%91.67%15, 19
charts/core/src/ChartTooltip/CustomTooltip/SeriesListItem
   SeriesListItem.tsx90%87.50%100%90.91%27–28
charts/core/src/ChartTooltip/CustomTooltip/SeriesListItemColorDot
   SeriesListItemColorDot.tsx100%100%100%100%
charts/core/src/Echart
   initializeEcharts.ts85.19%75%100%85.71%30–31, 73–74
   updateUtils.tsx0%0%0%0%10, 12, 12, 12–13, 17, 24, 26, 26, 26–28, 32, 46, 48–49, 49, 49–50, 50, 54, 57, 61, 68, 7, 9, 9, 9
   useEchart.ts53.51%41.11%67.86%58.17%109–110, 117, 124, 124, 124, 126, 126, 126, 126, 126–127, 130, 138, 140, 140, 140–141, 144, 153, 155, 155, 155–156, 160, 160, 160–161, 161, 161, 163, 174–175, 184–185, 188, 190, 192–193, 197, 210–211, 218–219, 222, 224–225, 227, 227, 227, 229, 229, 229–230, 230, 230–231, 235–236, 236, 236, 238–239, 239, 239–240, 245, 251, 256–258, 263, 271, 273, 273, 273–274, 277, 285, 287, 287, 287–288, 291, 297, 299, 299, 299–300, 303, 317, 320, 324, 324–325, 334, 347–350, 350, 357–358, 358, 365–367, 385–386, 423–424, 45–46, 59–60, 73–74
charts/core/src/Echart/utils
   updateUtils.ts97.06%90%100%100%26
charts/core/src/EventMarkers/BaseEventMarker
   BaseEventMarker.tsx0%0%0%0%18, 23–24, 27, 27, 27, 31–32, 32, 32, 40, 44–45, 60
   utils.ts0%0%0%0%102, 102, 115, 16, 33–34, 46, 51, 51, 55, 55, 60, 60, 74, 80, 80, 80–81
charts/core/src/EventMarkers/EventMarkerLine
   EventMarkerLine.tsx0%0%0%0%11, 13
charts/core/src/EventMarkers/EventMarkerPoint
   EventMarkerPoint.tsx0%0%0%0%11, 13
charts/core/src/Series
   Series.tsx0%0%0%0%23–26, 26, 26–27, 29–30, 30, 30, 32, 32, 32–34, 41, 44, 49, 63, 66
charts/core/src/Series/Bar
   Bar.tsx0%0%0%0%18, 18, 18, 18, 20, 22, 24, 42, 46, 48, 51, 64, 67, 9
charts/core/src/Series/Line
   Line.tsx0%100%0%0%12, 35–36, 44
charts/core/src/ThresholdLine
   ThresholdLine.tsx0%0%0%0%101, 103–104, 104, 104, 112, 114–115, 119, 30, 60, 60, 98–99
charts/core/src/testUtils
   makeSeriesData.testUtils.ts0%0%0%0%10, 106–107, 109, 111, 114–115, 117–118, 125, 127, 127, 138, 142–143, 146, 149, 15, 151–152, 16, 167, 17, 170–172, 175–176, 182, 185, 187–188, 192, 20,

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants