Repository navigation
[stable35] fix(settings): only save valid completed birth dates from the picker - #66431
Open
backportbot[bot] wants to merge 1 commit into
Open
backportbot[bot] wants to merge 1 commit into
backportbot[bot] wants to merge 1 commit into
Conversation
Typing a birth date in Personal info garbled the day/month segments as soon as the year was entered and could silently store a wrong date (Fixes #49303). Root causes and what this changes, including the lessons learned while fixing it: - Wrong event contract: NcDateTimePickerNative emits the legacy `input` event with `null` on every partial keystroke (@nextcloud/vue 8.x, via useModelMigration) and only forwards the raw native InputEvent in 9.x, so a listener on `input` either crashed on null (`e.getDate()` TypeError on every keystroke) or never receives a Date at all. `update:modelValue` carries `Date|null` on both major versions, so the handler now listens to that and ignores null (partially filled input). - Mid-typing state updates garble the native input: Chrome completes and normalizes the date early during year entry, so updating the component model on every emitted value changes the `:model-value` prop while the user types; each programmatic `input.value` patch resets the browser's segment editing state and the following digits land in the wrong segments. The state update and save now run inside the existing 500ms debounce, so the prop stays stable during a typing burst and only a settled value is accepted. - Empty birth date produced an Invalid Date that reached the picker as `0NaN-NaN-NaN` (rejected by the browser, but noisy and wasted renders). The display path is now null-safe. - Out-of-range years: the browser clamps overflowing year segments (e.g. a 7-digit year) to the ECMAScript Date maximum 275760-09-13, and the native input still accepts typing years wider than 4 digits. Values outside years 1..9999 are now discarded before saving, and `min`/`max` are passed to the picker so the browser flags and sanitizes such entries in the field. - JS quirk: `new Date(1, 0, 1)` maps years 0-99 to 1900+, so the min boundary is built with `setFullYear(1, 0, 1)`. - Testing lesson: Vue logs handler TypeErrors via console.error instead of rethrowing, so naive "does not throw" specs pass even with the original bug; the regression specs therefore assert saved payloads positively and spy on console.error (mutation-verified against the original code). Assisted-by: OpenCode:zai/glm-5.3 Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>
backportbot
Bot
requested review from
WSHAPER,
kristian-zendato,
pringelmann and
susnux
and removed request for
a team
November 6, 2026 20:24
This was referenced Nov 10, 2026
Merged
Merged
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #65197