-
-
Notifications
You must be signed in to change notification settings - Fork 221
feat: date picker segments #2671
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: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@@ -803,6 +810,138 @@ export function connect<T extends PropTypes>( | |||
}) | |||
}, | |||
|
|||
getSegmentInputProps() { |
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.
You can pass the index as props here
</output> | ||
|
||
<div {...api.getControlProps()}> | ||
<div {...api.getSegmentInputProps()}> |
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.
Let's rename this part to segmentGroup instead of segmentInput (since it's not technically an input)
inputMode: | ||
disabled || segment.type === "dayPeriod" || segment.type === "era" || !isEditable ? undefined : "numeric", | ||
enterKeyHint: "next", | ||
"aria-labelledby": dom.getInputId(scope, 0), // FIXIT: figure out the index |
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.
You can also pass the index from props. set the default to 0
"data-editable": dataAttr(segment.isEditable && !readOnly && !disabled), | ||
"data-placeholder": dataAttr(segment.isPlaceholder), | ||
style: { | ||
"caret-color": "transparent", |
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.
Should this be caretColor
?
ArrowLeft() { | ||
send({ type: "SEGMENT.ARROW_LEFT", focus: true }) | ||
}, | ||
ArrowRight() { | ||
send({ type: "SEGMENT.ARROW_RIGHT", focus: true }) | ||
}, | ||
ArrowUp() { | ||
send({ type: "SEGMENT.ARROW_UP", segment, focus: true }) | ||
}, | ||
ArrowDown() { | ||
send({ type: "SEGMENT.ARROW_DOWN", segment, focus: true }) | ||
}, | ||
PageUp(event) { | ||
send({ type: "SEGMENT.PAGE_UP", larger: event.shiftKey, focus: true }) | ||
}, | ||
PageDown(event) { | ||
send({ type: "SEGMENT.PAGE_DOWN", larger: event.shiftKey, focus: true }) | ||
}, | ||
Home() { | ||
send({ type: "SEGMENT.HOME", focus: true }) | ||
}, | ||
End() { | ||
send({ type: "SEGMENT.END", focus: true }) | ||
}, |
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.
After you get this working, I wonder if we can bundle these into a SEGMENT.CYCLE
or SEGMENT.INC/DEC
event to reduce the repetition here and in the machine.
📝 Description
Implements date picker segments functionality to allow inline editing of date components (day, month, year, etc.) for improved user experience. This feature enables users to navigate between date segments using keyboard and edit individual parts of the date without opening the calendar popup.
⛳️ Current behaviour (updates)
Currently, the date picker only supports input through a single text field or calendar selection. Users cannot navigate between individual date components (segments) like day, month, year using keyboard navigation or edit them individually.
🚀 New behaviour
💣 Is this a breaking change (Yes/No): No
This is an additive feature that doesn't break existing functionality.
📝 Additional Information
TODO:
getSegmentInputProps
)getSegments
,getSegmentProps
)processSegments
)aria-labelledby
attribute for segmentsgetSegmentState