Skip to content

Commit b5d8b8e

Browse files
authored
Merge pull request #3452 from dimagi/hotfix-prevent-dropdown-dismiss-during-text-change
Prevent Combobox dropdown list dismissal during text changed event
2 parents e3e2372 + 87a1650 commit b5d8b8e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/org/commcare/views/widgets/ComboboxWidget.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class ComboboxWidget extends QuestionWidget {
2929
private Vector<SelectChoice> choices;
3030
private Vector<String> choiceTexts;
3131
private Combobox comboBox;
32+
private boolean wasWidgetChangedOnTextChanged = false;
3233

3334
public ComboboxWidget(Context context, FormEntryPrompt prompt, ComboboxFilterRule filterRule) {
3435
super(context, prompt);
@@ -95,7 +96,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
9596

9697
@Override
9798
public void afterTextChanged(Editable s) {
98-
widgetEntryChanged();
99+
try {
100+
wasWidgetChangedOnTextChanged = true;
101+
widgetEntryChanged();
102+
} finally {
103+
wasWidgetChangedOnTextChanged = false;
104+
}
99105
}
100106
});
101107
}
@@ -115,7 +121,9 @@ private void fillInPreviousAnswer(FormEntryPrompt prompt) {
115121
@Override
116122
public IAnswerData getAnswer() {
117123
// So that we can see any error message that gets shown as a result of this
118-
comboBox.dismissDropDown();
124+
if(!wasWidgetChangedOnTextChanged) {
125+
comboBox.dismissDropDown();
126+
}
119127

120128
comboBox.autoCorrectCapitalization();
121129
String enteredText = comboBox.getText().toString();

0 commit comments

Comments
 (0)