fix(time-range): improve hour input focus behavior#3010
Open
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
Open
fix(time-range): improve hour input focus behavior#3010add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
When entering a single digit hour (3-9), automatically advance focus to the minute input field. This provides a more intuitive time entry experience by recognizing that hours 3-9 are single-digit values in 24-hour format. log: improve hour input focus behavior bug: PMS-349815
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the hour SpinBox onTextChanged logic so that focus automatically moves to the minute input after a single valid one-digit hour (3–9) or any two-digit hour is entered, improving time entry behavior. Sequence diagram for updated hour input focus behaviorsequenceDiagram
actor User
participant HourSpinBox
participant MinuteSpinBox
User->>HourSpinBox: Type first digit
activate HourSpinBox
HourSpinBox->>HourSpinBox: onTextChanged(text, focus, typingDigit)
alt text length is 1 and digit >= 3 and focus and typingDigit
HourSpinBox->>HourSpinBox: typingDigit = false
HourSpinBox->>MinuteSpinBox: forceActiveFocus()
HourSpinBox->>MinuteSpinBox: selectAll()
else text length is 1 and digit < 3 or not typingDigit or not focus
HourSpinBox-->>User: Remain in hour input
end
deactivate HourSpinBox
User->>HourSpinBox: Type second digit
activate HourSpinBox
HourSpinBox->>HourSpinBox: onTextChanged(text, focus, typingDigit)
alt text length is 2 and focus and typingDigit
HourSpinBox->>HourSpinBox: typingDigit = false
HourSpinBox->>MinuteSpinBox: forceActiveFocus()
HourSpinBox->>MinuteSpinBox: selectAll()
else conditions not met
HourSpinBox-->>User: Remain in hour input
end
deactivate HourSpinBox
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The logic in
onTextChangedduplicates theminuteInput.forceActiveFocus()/minuteInput.selectAll()block; consider extracting this into a small helper function or inline lambda to keep the branching readable and DRY. - When calling
parseInt(text, 10)on the single character, it may be safer to guard against non-numeric values (e.g., check with a regex or!isNaN(firstDigit)) so the behavior degrades predictably if the text ever contains unexpected input.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The logic in `onTextChanged` duplicates the `minuteInput.forceActiveFocus()` / `minuteInput.selectAll()` block; consider extracting this into a small helper function or inline lambda to keep the branching readable and DRY.
- When calling `parseInt(text, 10)` on the single character, it may be safer to guard against non-numeric values (e.g., check with a regex or `!isNaN(firstDigit)`) so the behavior degrades predictably if the text ever contains unexpected input.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
When entering a single digit hour (3-9), automatically advance focus to the minute input field. This provides a more intuitive time entry experience by recognizing that hours 3-9 are single-digit values in 24-hour format.
log: improve hour input focus behavior
bug: PMS-349815
Summary by Sourcery
Bug Fixes: