@@ -124,8 +124,6 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
124
124
RelativePosition .AdjacentTopRight
125
125
];
126
126
127
- final SelectionModel _defaultSelection = SelectionModel .single ();
128
-
129
127
final String popupId;
130
128
final String inputId;
131
129
@@ -135,24 +133,42 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
135
133
136
134
bool _isInitialized = false ;
137
135
138
- /// Whether to clear the text once the item is selected from the menu.
136
+ /// Whether to clear the input text once the item is selected from the menu.
137
+ ///
138
+ /// Defaults to false.
139
+ // TODO(google): rename this to shouldClearInputOnSelection.
139
140
@Input ()
140
141
bool shouldClearOnSelection = false ;
141
142
143
+ /// Whether to clear the selected value from the selection model when the
144
+ /// input text changes.
145
+ ///
146
+ /// Defaults to true.
147
+ @Input ()
148
+ bool shouldClearSelectionOnInput = true ;
149
+
142
150
/// Whether to cause dropdown to be closed on activation.
151
+ ///
152
+ /// Defaults to true.
143
153
@Input ()
144
154
bool closeOnActivate = true ;
145
155
146
156
/// Whether to hide the checkbox before the selection item for multi-select.
157
+ ///
158
+ /// Defaults to false.
147
159
@Input ()
148
160
bool hideCheckbox = false ;
149
161
150
162
/// Whether the popup should automatically reposition itself based on space
151
163
/// available relative to the viewport.
164
+ ///
165
+ /// Defaults to true.
152
166
@Input ()
153
167
bool enforceSpaceConstraints = true ;
154
168
155
169
/// Whether to clamp the popup position so that it never goes offscreen.
170
+ ///
171
+ /// Defaults to false.
156
172
@Input ()
157
173
bool constrainToViewport = false ;
158
174
@@ -187,6 +203,8 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
187
203
/// [selection] are changed:
188
204
/// 1) first selected value in [selection] is active in [options]
189
205
/// 2) if [selection] has no selected values, nothing is active in [options]
206
+ ///
207
+ /// Defaults to false.
190
208
@Input ()
191
209
bool initialActivateSelection = false ;
192
210
@@ -195,10 +213,13 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
195
213
/// Allow filtering of suggestions as the user is typing.
196
214
///
197
215
/// When `false` always show the full list of suggestions.
216
+ /// Defaults to true.
198
217
@Input ()
199
218
bool filterSuggestions = true ;
200
219
201
220
/// Whether to close on enter even for string non matching options.
221
+ ///
222
+ /// Defaults to false.
202
223
@Input ()
203
224
bool closeOnEnter = false ;
204
225
@@ -208,6 +229,8 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
208
229
209
230
/// Whether or not the suggestion popup width is at least as wide as the input
210
231
/// width.
232
+ ///
233
+ /// Defaults to false.
211
234
@Input ()
212
235
bool popupMatchInputWidth = false ;
213
236
@@ -231,6 +254,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
231
254
/// Show or hide the trailing close icon.
232
255
///
233
256
/// Clicking on the icon clears the input text and hides the popup.
257
+ /// Defaults to false.
234
258
@Input ()
235
259
bool showClearIcon = false ;
236
260
@@ -312,7 +336,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
312
336
if (_cd != null ) {
313
337
_cd.valueAccessor = this ;
314
338
}
315
- selection = _defaultSelection ;
339
+ selection = SelectionModel . single () ;
316
340
}
317
341
318
342
/// Publishes events when input text changes (on keypress.)
@@ -575,7 +599,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
575
599
return false ;
576
600
}
577
601
578
- if (selection != _defaultSelection &&
602
+ if (shouldClearSelectionOnInput &&
579
603
! shouldClearOnSelection &&
580
604
_lastSelectedItem != null ) {
581
605
// deselect previously selected item as the component was not asked to
0 commit comments