Skip to content

Conversation

@avazirna
Copy link
Contributor

@avazirna avazirna commented Dec 4, 2025

Product Description

This addresses an issue introduced by #3445. 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).

Dropdown list dismissed on every text changeExpected behavior
comboboxwidget_dropdown_list_issue.webm
comboboxwidget_dropdown_list_issue_fix.webm

Ticket: https://dimagi.atlassian.net/browse/QA-8262

Technical Summary

The issue occurs because widgetEntryChanged() calls getAnswer(), and within the ComboboxWidget, this method dismisses the dropdown list. The solution here was to prevent the dismissal when the widgetEntryChanged() is called during an afterTextChanged() event.

Safety Assurance

Safety story

Successfully tested locally.

QA Plan

QA will retest this fix to confirm that the issue has been resolved.

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

📝 Walkthrough

Walkthrough

The PR modifies ComboboxWidget.java to track whether widget changes originate from text input. A private boolean flag wasWidgetChangedOnTextChanged is introduced and managed via a try/finally block in the TextWatcher.afterTextChanged method around the widgetEntryChanged() call. The getAnswer() method is updated to conditionally dismiss the dropdown only when the flag indicates the change did not come from text input, allowing the dropdown to remain visible during active typing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Single file modification with a straightforward flag-based state management pattern
  • Private flag addition with clear initialization and lifecycle within try/finally
  • Minor conditional logic adjustment in dropdown dismissal

Areas to verify:

  • Flag is properly initialized to a default state (likely false)
  • Try/finally structure guarantees flag reset even if widgetEntryChanged() throws an exception
  • The flag check in getAnswer() correctly prevents dropdown dismissal during text input

Possibly related PRs

Suggested reviewers

  • shubham1g5
  • Jignesh-dimagi

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: preventing the Combobox dropdown dismissal during text changes, which aligns with the core issue being fixed.
Description check ✅ Passed The pull request description addresses most required sections including product description, technical summary, safety story, and QA plan. However, the Automated test coverage section is missing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix-prevent-dropdown-dismiss-during-text-change

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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: Consider adding a documentation comment for clarity.

While the flag name is descriptive, a brief comment explaining its purpose would help future maintainers understand why this flag exists and how it's used to control dropdown behavior during text input.

For example:

+    // Tracks whether widgetEntryChanged() was called from afterTextChanged() to prevent
+    // dropdown dismissal during active typing
     private boolean wasWidgetChangedOnTextChanged = false;

124-126: LGTM! Logic correctly prevents dropdown dismissal during text input.

The conditional dismissal ensures the dropdown remains visible while users are actively typing (allowing them to see filtered results), while still dismissing appropriately when items are selected or focus is lost.

Minor style note: Consider adding a space after if for consistency with Java conventions:

-        if(!wasWidgetChangedOnTextChanged) {
+        if (!wasWidgetChangedOnTextChanged) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3e2372 and 87a1650.

📒 Files selected for processing (1)
  • app/src/org/commcare/views/widgets/ComboboxWidget.java (3 hunks)
🔇 Additional comments (1)
app/src/org/commcare/views/widgets/ComboboxWidget.java (1)

99-104: LGTM! Proper use of try-finally for flag management.

The try-finally pattern correctly ensures that wasWidgetChangedOnTextChanged is always reset to false after widgetEntryChanged() completes, even if an exception is thrown. This prevents the flag from being left in an incorrect state.

Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see it in video attached clearly but can you confirm that the dropdown gets dismissed correctly when user clicks on an option inside dropdown ?

@avazirna
Copy link
Contributor Author

avazirna commented Dec 5, 2025

I can't see it in video attached clearly but can you confirm that the dropdown gets dismissed correctly when user clicks on an option inside dropdown ?

Yes, it does.

@avazirna avazirna merged commit b5d8b8e into commcare_2.61 Dec 5, 2025
2 checks passed
@avazirna avazirna deleted the hotfix-prevent-dropdown-dismiss-during-text-change branch December 5, 2025 07:54
@shubham1g5
Copy link
Contributor

@avazirna can we link the Jira ticket please to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants