Fix #1459: Validator highlights on tap-away, not just VKB Enter#5123
Merged
Conversation
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Contributor
Cloudflare Preview
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
…1459) The 2015 reporter noted that when an invalid value was left in a TextField and the user moved focus by tapping into a different field (rather than the VKB 'next' / Enter button), the leaving field was not highlighted as invalid until the user returned to it. The action-listener path Validator.bindDataListener wired up only fires for VKB Enter / action, so tapping a different field skipped the validation entirely. The class did register a focus listener -- but only when showErrorMessageForFocusedComponent was set, and its focusLost handler was empty. Register an unconditional focus listener at the top of bindDataListener whose only job is to call validate(cmp) on focus loss. The conditional error-popup listener stays as it was; this new listener fires before it and runs regardless of the popup config so every binding path catches the tap-away case. Closes #1459. Adds maven/core-unittests/.../ValidatorFocusLossHighlightTest.java: - focusLossOnAnotherFieldFlagsTheLeftFieldAsInvalid: start with a valid value, clear it to an invalid value, requestFocus on the first field, then requestFocus on the second; the first must now report v.isValid(first) == false. Pre-fix this stayed true until the field regained focus. - focusLossDoesNotFalselyInvalidateAValidField: same sequence with valid content -- focus loss must not flip a valid field to invalid. Full Validator sweep (15 tests) stays green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
03d2012 to
1fb9af0
Compare
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
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.
Summary
Closes #1459. The 2015 reporter noted that when an invalid value was left in a TextField and the user moved focus by tapping into a different field (rather than the VKB 'next' / Enter button), the leaving field was not highlighted as invalid until the user returned to it.
Root cause
Validator.bindDataListenerwires the validator up two ways:showErrorMessageForFocusedComponentwas set, and thefocusLosthandler was empty.So a tap into another field never went through the action-listener path and the focus listener (when registered at all) just discarded the event.
Fix
Register an unconditional focus listener at the top of
bindDataListenerwhose only job is to callvalidate(cmp)on focus loss. The conditional error-popup listener stays as it was; this new listener fires alongside it and runs regardless of the popup config, so every binding path now catches the tap-away case the 2015 reporter described.Test plan
ValidatorFocusLossHighlightTestwith two cases:focusLossOnAnotherFieldFlagsTheLeftFieldAsInvalid: start with a valid value, clear it to an invalid value,requestFocuson the first field, thenrequestFocuson the second. The first must now reportv.isValid(first) == false. Pre-fix this stayedtrueuntil the field regained focus — that's the 2015 symptom.focusLossDoesNotFalselyInvalidateAValidField: same sequence with valid content. Focus loss must not flip a valid field to invalid.*Validator*sweep — 15 tests includingValidatorTest,Validator#3Test— stays green.🤖 Generated with Claude Code