fix(NcDateTimePicker): handle text input for default formatting - #8657
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8657 +/- ##
=======================================
Coverage 53.31% 53.31%
=======================================
Files 109 109
Lines 3697 3697
Branches 1083 1082 -1
=======================================
Hits 1971 1971
Misses 1472 1472
Partials 254 254 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // | ||
| // One big snapshot test to not infalte number of test cases. | ||
| // This keeps reporting clean and runs faster. | ||
| test('all locales format', async ({ mount }) => { |
There was a problem hiding this comment.
Do you want to keep this snapshots tests?
I found them useful when developing to understand the:
- edge cases related to different locales (and sometimes browsers)
- impact of formatting changes
- e.g., by diffing them between the two commits of this PR
There was a problem hiding this comment.
we probably expect them to fail for certain languages? so we can maybe limit snapshots to these one, to not commit 15K lines?
496104b to
9a35785
Compare
| return (input: Date | [Date, Date]) => Array.isArray(input) | ||
| ? formatter.formatRange(input[0], input[1]) | ||
| : formatter.format(input) | ||
| switch (props.type) { |
There was a problem hiding this comment.
If we get Vuepic/vue-datepicker#1286 fixed update to a newer versions of Vuepic, we can use textInput.format to specify a format that only applies when the user focuses the input.
With that, we could keep using Intl.DateTimeFormat for formatting the text that is shown by default. And with that, do not change the behavior at all.
So the decision would be between:
- Using same format for preview and input
- Drawbacks
- for some languages, the format changes (compared to impl. on
main)- e.g., "02.01.2000, 03:04" becomes "02.01.2000 03:04" for "de" (comma is removed)
- no shortend form for durations
- e.g., "Jan 1 – 7, 2000" becomes "Jan 1, 2000 - Jan 7, 2000" for "en-US"
- for some languages, the format changes (compared to impl. on
- Using different (but mostly similar) for formats for preview and input
- Drawbacks
- Text input changes/flickers when use focuses/leaves the text input
There was a problem hiding this comment.
This PR implements solution 1..
Solution 2. would be blocked by Vuepic/vue-datepicker#1286
9a35785 to
f103fd8
Compare
f103fd8 to
141b4e8
Compare
141b4e8 to
e416fa9
Compare
Signed-off-by: Oleksandr Dzhychko <hey@oleks.dev>
e416fa9 to
30ff669
Compare
For some locales, the default formatting changes to accommodate the used parsing solution. Fixes #8635 Signed-off-by: Oleksandr Dzhychko <hey@oleks.dev>
30ff669 to
0a44a84
Compare
kra-mo
left a comment
There was a problem hiding this comment.
Not an expert in localization specifically, it looks good from what I understand, so unless someone else has feedback, consider it approved from the design side.
|
I'll check now, maybe it's okay) |
Antreesy
left a comment
There was a problem hiding this comment.
code change itself it fine IMO
| // | ||
| // One big snapshot test to not infalte number of test cases. | ||
| // This keeps reporting clean and runs faster. | ||
| test('all locales format', async ({ mount }) => { |
There was a problem hiding this comment.
we probably expect them to fail for certain languages? so we can maybe limit snapshots to these one, to not commit 15K lines?
There was a problem hiding this comment.
we can maybe keep it as .json file - Vite/Playwright should support importing and using it fine?
There was a problem hiding this comment.
I thought about it again. I think we can limit it now to the locales supported by date-fns. Including all locales supported by Nextcloud was only interesting from the migration from Intl.DateFormat to localization by date-fns.
Applied in #8825 (removes ~20k lines from snapshots)
@Antreesy No, none of them is expected to fail immediately. They should only fail if the formatting changes. This can happen if (a) the But I did what is described in #8657 (comment) |
What I meant under 'language that fails' is more 'language that caused issues on parsing'. But agree in general that limiting to date-fns available locales sounds ok to me. By the diff, I see that some secondary locales were dropped from snapshots, they would probably fall back to more generic locales anyway |
Handle text input when default formatting is used.
I tried not to change the existing formatting.
But the default formatting needed to change to accommodate the used parsing solution (locale information available in
date-fns/locale)Notable changes in the formatting are:
e.g., "02.01.2000, 03:04" becomes "02.01.2000 03:04" for "de" (comma is removed)
e.g., "Jan 1 – 7, 2000" becomes "Jan 1, 2000 - Jan 7, 2000" for "en-US"
This could be considered a breaking change, because things are now displayed differently.
But it could also be considered not to be breaking, because we still display the same information but in a new format, that is improved to accommodate text input. I consider it non-breaking and better than not allowing text input.
More details on how we could accommodate parsing without changing the preview format at all can be found in #8657 (comment)
☑️ Resolves
🖼️ Screenshots
Before
Screencast.from.2026-06-03.16-17-41.webm
After
Screencast.from.2026-06-03.16-16-14.webm
🚧 Tasks
🏁 Checklist
stable8for maintained Vue 2 version or not applicable