-
Notifications
You must be signed in to change notification settings - Fork 72
[LG-5532] feat(time-input): Segment misc #3387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: LG-5532/segments-display-values-state
Are you sure you want to change the base?
[LG-5532] feat(time-input): Segment misc #3387
Conversation
…for time input components
…ngodb/leafygreen-ui into LG-5532/segments-callback
…ngodb/leafygreen-ui into LG-5532/segments-callback
|
| }} | ||
| /> | ||
| )} | ||
| {is24HourFormat && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a story for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements miscellaneous improvements to the TimeInputSegment component, focusing on segment reference management, event handling, and UI enhancements. The changes add support for segment refs to enable proper focus management, implement onChange event handling for individual segments, and add a "24 hours" label for 24-hour time formats.
Key Changes:
- Added segment reference management system using
useDynamicRefshook - Implemented
onSegmentChangehandler to fire synthetic change events when individual segments update - Added "24 hours" label UI for 24-hour time format with corresponding styling
- Enhanced
TimeInputSelectcomponent with size prop and improved variable naming
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/time-input/src/testing/testUtils.ts | Creates mock segment refs for testing |
| packages/time-input/src/shared.types.ts | Defines SegmentRefs type for managing segment references |
| packages/time-input/src/constants.ts | Adds "24 hours" display text constant |
| packages/time-input/src/TimeInputSelect/TimeInputSelect.tsx | Adds size prop and improves variable naming from u to unitOption |
| packages/time-input/src/TimeInputInputs/TimeInputInputs.tsx | Implements segment change handling, click handling, and 24-hour label rendering |
| packages/time-input/src/TimeInputInputs/TimeInputInputs.styles.ts | Adds styling for wrapper and 24-hour label |
| packages/time-input/src/TimeInputInputs/TimeInputInputs.spec.tsx | Adds tests for 24-hour label rendering in both 12/24 hour formats |
| packages/time-input/src/TimeInputBox/TimeInputBox.types.ts | Adds props for segment change handler and segment refs |
| packages/time-input/src/TimeInputBox/TimeInputBox.spec.tsx | Implements test for onSegmentChange callback |
| packages/time-input/src/TimeInput.stories.tsx | Adds onChange console logging to Storybook |
| packages/time-input/src/Context/TimeInputContext/useTimeInputComponentRefs.ts | Creates hook for managing segment refs |
| packages/time-input/src/Context/TimeInputContext/TimeInputContext.types.ts | Adds refs to context type |
| packages/time-input/src/Context/TimeInputContext/TimeInputContext.tsx | Integrates segment refs into context provider |
| z-index: 0; // Establish new stacking context | ||
| `, | ||
| { | ||
| [twelveHourFormatStyles]: !is12HourFormat, |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition !is12HourFormat applies twelveHourFormatStyles when the format is 24-hour, but the styles are named for 12-hour format. This should be is12HourFormat instead of !is12HourFormat.
| [twelveHourFormatStyles]: !is12HourFormat, | |
| [twelveHourFormatStyles]: is12HourFormat, |
| hour: getSegmentRef('hour') || undefined, | ||
| minute: getSegmentRef('minute') || undefined, | ||
| second: getSegmentRef('second') || undefined, |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The || undefined is redundant since getSegmentRef already returns a ref object or undefined. Remove the || undefined clauses from all three lines.
| hour: getSegmentRef('hour') || undefined, | |
| minute: getSegmentRef('minute') || undefined, | |
| second: getSegmentRef('second') || undefined, | |
| hour: getSegmentRef('hour'), | |
| minute: getSegmentRef('minute'), | |
| second: getSegmentRef('second'), |
|
Size Change: +920 B (+0.05%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
…ngodb/leafygreen-ui into LG-5532/segments-callback
…and improve styling for 24-hour format
|
Coverage after merging LG-5532/segments-callback into LG-5532/segments-display-values-state will be
Coverage Report for Changed Files
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
✍️ Proposed changes
🎟 Jira ticket: Name of ticket
This PR implements various improvements, including support for segment refs to enable proper focus management, implementation of onChange event handling for individual segments, addition of a "24 hours" label for 24-hour time formats, and disabled states.
This PR is the fifth PR in a chain of PRs
✅ Checklist
🧪 How to test changes