-
-
Notifications
You must be signed in to change notification settings - Fork 45
Prevent Combobox dropdown list dismissal during text changed event #3449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThis PR modifies Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/src/org/commcare/views/widgets/ComboboxWidget.java (2)
32-32: Flag introduction is fine; consider a slightly clearer name (optional).The added boolean cleanly scopes the behavior change and is localized to this widget. If you touch this again, consider a slightly shorter/more precise name (e.g.
isDuringTextChangeEvent) to reduce line length and better reflect that it’s toggled inafterTextChanged, notonTextChangedspecifically.
97-102: Guard flag reset withtry/finallyto avoid stale state on exception.If
widgetEntryChanged()ever throws,isEntryChangedEventFiredDuringOnTextChangedstaystrueand subsequentgetAnswer()calls will never dismiss the dropdown. Wrapping the call intry/finallymakes this more robust:@Override public void afterTextChanged(Editable s) { - isEntryChangedEventFiredDuringOnTextChanged = true; - widgetEntryChanged(); - isEntryChangedEventFiredDuringOnTextChanged = false; + boolean previous = isEntryChangedEventFiredDuringOnTextChanged; + isEntryChangedEventFiredDuringOnTextChanged = true; + try { + widgetEntryChanged(); + } finally { + isEntryChangedEventFiredDuringOnTextChanged = previous; + } }This also handles any future nested text-change flows correctly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/src/org/commcare/views/widgets/ComboboxWidget.java(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Lint Code Base
🔇 Additional comments (1)
app/src/org/commcare/views/widgets/ComboboxWidget.java (1)
121-123: Conditional dropdown dismissal matches the described UX fix.Gating
dismissDropDown()on!isEntryChangedEventFiredDuringOnTextChangedcleanly solves the reported issue: text-drivenwidgetEntryChanged()calls won’t close the dropdown, while focus changes, item clicks, and othergetAnswer()call sites keep the old behavior. This looks consistent with the PR objective.
3de6103 to
e6e6063
Compare
| private Vector<SelectChoice> choices; | ||
| private Vector<String> choiceTexts; | ||
| private Combobox comboBox; | ||
| private boolean isEntryChangedEventFiredDuringOnTextChanged = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can we shorten this variable name? Maybe processingWidgetEntryTextChange or processingTextChangeEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can.
|
Superseded by #3452 |
Product Description
This addresses an issue introduced by this PR. QA reported that when users manually delete the selected item in the ComboboxWidget, the dropdown list is dismissed, preventing users from seeing the filtered items (see video below). This occurs because
widgetEntryChanged()callsgetAnswer(), and within theCommboboxWidget, this method dismisses the dropdown list.Technical Summary
The solution here was to prevent the dismissal when the
widgetEntryChanged()is called during anafterTextChanged()event.Safety Assurance
Safety story
Successfully tested locally.
Labels and Review