-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat: Date Field add data-placeholder attribute and delete improv #808
base: next
Are you sure you want to change the base?
Conversation
|
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Wow, thanks for this! I will give it a look very soon! |
CleanShot.2024-10-26.at.13.52.27.mp4Here's some interesting behavior that we should perhaps account for. Should we deselect the text once it is complete? If it's fully selected like that, it feels like it would just keep overwriting everything selected. |
Interesting, is something like the that desirable? CleanShot.2024-10-26.at.21.27.37-converted.mp4 |
If the whole block is highlighted, my instinct says the next number I type should replace the entirety of the highlighted block, similar to how it would work if you highlighted editable text and started typing, right? |
I am totally on your side, but with your current implementation you aren't able to input a single value / replace the entirety, because you prepend the value with zeros. Therefor (bc of consistency) my implementation is "more" correct i think. In the Svelte 4 Version of bits or in React Aria that isn't the case. Here you can input "5" in the year segment for example and the value would stay that way (which i prefer) instead of 0005. If you want to change that behavior your idea would be more correct. |
Changes
Currently i am porting Origin UI to Svelte (See). As i was trying to port the Components over i saw that you are handling the placeholder styles with:
The React Aria Datepicker changes the
aria-valuetext
based on the locale. So the styling would only work if the locale isen
. If you decide to implement translation based on the locale in the future, the current implementation would break styling.On top of that, as i was writing the tests for that i saw that a
CTRL + A + BACKSPACE / DELETE
deletion was not reliably possible. I don't really know if you want to change that. Again, the React Aria implementation doesn't have that. You can't evenCTRL + A
a Segment (which i find weird). 🤷♂️1. TLDR: Improved placeholder handling
data-placeholder="true"
attribute to empty date/time segmentsaria-[valuetext=Empty]:text-muted-foreground
styling approachvaluetext
which varies based on locale2. TLDR: Enhanced deletion behavior
Test Coverage
Added two tests:
Visual Changes
Empty date/time segments now use data-placeholder attribute for styling
Visual appearance remains the same, but implementation is more robust
Testing Instructions
Open the
DateField
component (or based on that)Try selecting all text in any segment (CTRL + A)
Verify deletion works with both:
Backspace
keyDelete
keyVerify placeholder styling appears correctly when segments are empty