feat(components): [time-picker] add save-on-blur prop#23531
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a public Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Input
participant PickerLogic
participant Spinner
User->>Input: focus
Input->>PickerLogic: request displayValue()
Note right of PickerLogic: if isTimePicker && valueIsEmpty && !saveOnBlur
PickerLogic-->>Input: return "" (empty)
opt programmatic spinner adjust
PickerLogic->>Spinner: adjustSpinner(type)
Spinner->>Spinner: set ignoreScroll[type] = true (when !saveOnBlur)
Spinner->>Spinner: requestAnimationFrame -> reset ignoreScroll[type]
end
User->>Spinner: user scroll
Spinner->>PickerLogic: handleScroll(type)
alt ignoreScroll[type] && !saveOnBlur
PickerLogic-->>Spinner: early return (ignore)
else
PickerLogic-->>Spinner: process scroll event
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
|
🧪 Playground Preview: https://element-plus.run/?pr=23531 |
save-on-blur prop
rzzf
left a comment
There was a problem hiding this comment.
Could you update the documentation?
Submitted, thanks! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/en-US/component/time-picker.md`:
- Line 78: Update the description for the save-on-blur prop in the Time Picker
docs: replace the current phrase "Whether to keep the input empty on focus when
no value is selected" with a corrected description such as "Whether to auto-fill
the input with the current time on focus when no value is selected" or "Whether
to save the time value on blur instead of keeping the input empty on focus" so
the wording matches the implemented default (saveOnBlur=true) and behavior;
ensure the table cell for the save-on-blur row (header symbol save-on-blur) is
updated accordingly and retains the default value true and type [boolean].
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Dsaquel
left a comment
There was a problem hiding this comment.
Sorry for the late review,
I think it's good, can we also propagate the effect until the user confirm the value ? Or it too complicated ?
Sorry for the oversight; I have already fixed it. Currently, when |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/components/time-picker/src/common/props.ts (1)
108-114: ClarifysaveOnBlurdescription to include blur behavior.Current text mentions focus only, but the implementation also changes blur-time commit/cancel flow.
✏️ Suggested wording
- * `@description` Whether to keep the input empty on focus when no value is selected. + * `@description` Whether to keep empty time input from auto-filling and avoid saving on blur unless explicitly confirmed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/components/time-picker/src/common/props.ts` around lines 108 - 114, Update the JSDoc for the saveOnBlur prop in props.ts to mention both focus and blur behavior: clarify that when true the input retains its displayed value on focus and commits the tentative selection on blur, and when false the input can be cleared on focus and tentative changes are discarded on blur (i.e., cancel/commit flow). Reference the saveOnBlur prop object to locate the description to replace.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/components/time-picker/src/common/picker.vue`:
- Around line 298-302: The time-range panel defines handleCancel but never
exposes it, so afterBlur's call to pickerOptions.value.handleCancel?.() is a
no-op for timerange; in panel-time-range.vue, after defining handleCancel emit
the 'set-picker-option' event to register it (i.e. emit the set-picker-option
with the key 'handleCancel' and the handleCancel function) so pickerOptions
receives the handler and the afterBlur branch works the same as
panel-time-pick.vue.
---
Nitpick comments:
In `@packages/components/time-picker/src/common/props.ts`:
- Around line 108-114: Update the JSDoc for the saveOnBlur prop in props.ts to
mention both focus and blur behavior: clarify that when true the input retains
its displayed value on focus and commits the tentative selection on blur, and
when false the input can be cleared on focus and tentative changes are discarded
on blur (i.e., cancel/commit flow). Reference the saveOnBlur prop object to
locate the description to replace.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/components/time-picker/src/common/picker.vuepackages/components/time-picker/src/common/props.tspackages/components/time-picker/src/time-picker-com/panel-time-pick.vue
|
If I understand correctly, when Video20260303-131328.mp4 |
Yes, that’s exactly the effect. |
|
Thanks for your time, i ran into an issue:
Expected: the input should be cleared again but it's actually set the initial value. |
Thanks for pointing that out. I've fixed it. |
|
@snowbitx I optimized the |
Okay.I see see |
If you think it looks good, we can merge it. 🚀 |
It looks good to me. I just have a small suggestion — would it be possible to replace any with unknown? What do you think? 😊 |
Your approach to handling reactivity is more elegant. Thanks — I learned something from it. 😊 |
Sure. |
|
@snowbitx Thanks for your contribution! ❤️ |

Please make sure these boxes are checked before submitting your PR, thank you!
devbranch.fixed: #23252
demo
Summary by CodeRabbit
New Features
Tests
Documentation