-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow partial input #42
Conversation
Deploying timescape with
|
Latest commit: |
a5f57c2
|
Status: | ✅ Deploy successful! |
Preview URL: | https://404e3618.timescape.pages.dev |
Branch Preview URL: | https://feat-allow-partial-input.timescape.pages.dev |
Hey @dan-lee, thank you so much for the prompt response! It seems the updated behavior currently only clears segments with Other than this, the current behavior aligns well with native HTML date inputs, which is great. However, I wonder if partial input should be the default behavior, as it seems more user-friendly and closer to standard date input handling (if we’re using native HTML input as our reference). If so, perhaps the prop could be renamed in a negative form, like Thanks again for considering this! As a bonus note, initially I compared the behavior with React Aria, where pressing backspace or delete removes characters one by one within a segment, moving the cursor back to the previous segment once a segment is empty. Screen.Recording.2024-11-03.at.10.14.48.PM.movAfter double-checking with native HTML inputs and MUI, though, they seem to align with your current behavior, so I think we’re good here! 😊 |
I agree with your points! I will implement this; will stir up some things though :) We probably need to provide default placeholders when this is the new behavior. I am thinking of just providing About backspace/delete: I think delete could clear the entire segment (like it is right now) and backspace could remove character by character in a segment, like ARIA. Wdyt? |
I agree that having default placeholders similar to native html input. E.g,
Regarding to this, I've did some comparisons with other libraries to check their handling of
as of 2024 Nov 4th I think having Thank you! |
Wow, that's great! Thanks for the effort. This is a beautiful summary. Also for the great feedback, really appreciated 🙏 I wish OSS was always this fun and engaging :) For what it's worth, React Aria seems to remove character by character using the delete and backspace keys. I still think it's better UX to have those separated, as you suggested. |
Ah, thanks for catching that—I’ve updated the table to reflect this accurately. I also just thought of an idea: what if we allow users to control this behavior using props, perhaps something like
This way, we could support both UX options. By default, it could clear the entire segment for both Of course, adding this control might expand the API surface and increase maintenance, so it would need to be considered carefully. If we want to keep things simple, I am leaning towards following the behavior of React Aria if possible, otherwise native date input. And on a side note, I really appreciate the work you’re doing here—there’s such a need for a headless date field library like this! I’ve actually been looking for something like this for a long time. Thank you for making it happen and for all the thoughtful engagement along the way. 🚀 |
🦋 Changeset detectedLatest commit: a5f57c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@junwen-k can you check again now? :) |
@dan-lee I took a closer look and did a comparison using this StackBlitz example. Here are a few differences I noticed:
Overall, it looks really good—these are just a few observations I came across. Thanks for the fantastic work and all your effort on this! |
Thanks for your feedback @junwen-k, sorry took me some time :)
That's true, the library is a bit opinionated about how to render dates. I plan to add a new option, Thinking of an API like: formatSegment: (opts: {
incomplete: boolean;
value: Date;
valueAsString: string;
type: DateType;
options: Options;
}) => string | number | undefined
I am a bit hesitant to do this, because intermediate steps are not full dates. Arrow up/down will trigger change and switching left/right between fields also does. Whenever a date is "complete" from the libraries POV the date change is happening.
Should be fixed :)
For now just fixed it by rendering negative values without 0 padding. I think it's an edge case. Could be fixed in different ways by the proposal in bullet point 1. |
b451ecc
to
a5f57c2
Compare
Hi! I just realized that negative year values are actually possible, which I initially thought didn’t make sense. In React Aria, when the year value is negative, it appends "BC." However, the underlying value doesn't seem to reflect BC and the only way to achieve this is by manually decrementing the year—typing a negative value directly doesn’t seem to work. Here’s a demo of it: Screen.Recording.2024-11-13.at.2.49.32.PM.movAs for the native HTML input, I noticed that it cycles to 275760 when trying to go below the valid year range. Here’s what I observed: Screen.Recording.2024-11-13.at.2.53.23.PM.movThank you for your patience and for the great work you've put into this! It’s been a while since my last reply, and I really appreciate you waiting for my response. Everything else looks pretty good, just wanted to share these observations. |
Thanks for your feedback @junwen-k! I went ahead and merged it and will cut a release soon. |
Addresses #41
This adds a new option
disallowPartial
to allow partial input dates and set it as default. Only when it's completely filled out,options.date
returns aDate
instance; otherwise it'sundefined
.The
Delete
key clears a selected input field.Backspace
returns character by character in a segment.Preview here: https://feat-allow-partial-input.timescape.pages.dev/?path=%2Fstory%2Froot-timescape--partial