fix(timepicker): prevent extra digits when editing incomplete time (#DS-3985) - #1854
fix(timepicker): prevent extra digits when editing incomplete time (#DS-3985)#1854KamilEmeleev wants to merge 2 commits into
Conversation
🚨 E2E tests failedReview the report for details. 💡 Comment |
| this.selectionStart = selectionStart; | ||
| this.selectionEnd = newTimeObj ? selectionEnd : selectionStart; | ||
|
|
||
| this.createSelectionOfTimeComponentInInput((selectionStart as number) + 1); |
There was a problem hiding this comment.
selectionStart может быть null, нигде выше это не проверяется, надо добавить проверку
There was a problem hiding this comment.
Pull request overview
Fixes an input-masking edge case in KbqTimepicker where repeatedly typing digits into an incomplete time (e.g. 11:1) could grow a segment unbounded (e.g. 911:1, 9911:1). The change introduces normalization that limits each time segment to two digits and updates the input view while the value is still incomplete, keeping the caret behavior consistent.
Changes:
- Add
normalizeTimePartand updatereplaceNumbersto clamp and trim each time segment to a max of 2 digits. - Update
onInputto rewrite normalized incomplete values back to the input and maintain caret movement/selection behavior. - Add unit + Playwright coverage for the “growing digits” scenario, and add stable
data-testidhooks for E2E selection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/components/timepicker/timepicker.directive.ts | Normalizes oversized time parts and rewrites incomplete values to prevent unbounded growth while preserving caret behavior. |
| packages/components/timepicker/timepicker.spec.ts | Adds unit tests for trimming/clamping behavior and ensuring intermediate typing states remain unchanged. |
| packages/components/timepicker/e2e.ts | Adds data-testid attributes to timepicker inputs for reliable E2E targeting. |
| packages/components/timepicker/e2e.playwright-spec.ts | Adds an E2E regression test covering repeated digit insertion on an incomplete value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/redeploy-preview |
|
🔄 Redeploying documentation preview. |
|
редеплой сообщение с ссылкой на доку не показал, вот адрес |
Summary
You could type endless digits into an incomplete value:
11:1plus digits at the start grew to911:1,9911:1. Nothing limited how long a time part could be.List of notable changes:
normalizeTimePartbecause the old check only caught big numbers, not long ones like001replaceNumbersto cut every part down to two digitsonInputto write the fixed value back while the time is still incomplete, and move the caret to the next partWhat should reviewers focus on?
1,12:,12:3are left alone