@@ -124,8 +124,6 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
124124 RelativePosition .AdjacentTopRight
125125 ];
126126
127- final SelectionModel _defaultSelection = SelectionModel .single ();
128-
129127 final String popupId;
130128 final String inputId;
131129
@@ -135,24 +133,42 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
135133
136134 bool _isInitialized = false ;
137135
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.
139140 @Input ()
140141 bool shouldClearOnSelection = false ;
141142
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+
142150 /// Whether to cause dropdown to be closed on activation.
151+ ///
152+ /// Defaults to true.
143153 @Input ()
144154 bool closeOnActivate = true ;
145155
146156 /// Whether to hide the checkbox before the selection item for multi-select.
157+ ///
158+ /// Defaults to false.
147159 @Input ()
148160 bool hideCheckbox = false ;
149161
150162 /// Whether the popup should automatically reposition itself based on space
151163 /// available relative to the viewport.
164+ ///
165+ /// Defaults to true.
152166 @Input ()
153167 bool enforceSpaceConstraints = true ;
154168
155169 /// Whether to clamp the popup position so that it never goes offscreen.
170+ ///
171+ /// Defaults to false.
156172 @Input ()
157173 bool constrainToViewport = false ;
158174
@@ -187,6 +203,8 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
187203 /// [selection] are changed:
188204 /// 1) first selected value in [selection] is active in [options]
189205 /// 2) if [selection] has no selected values, nothing is active in [options]
206+ ///
207+ /// Defaults to false.
190208 @Input ()
191209 bool initialActivateSelection = false ;
192210
@@ -195,10 +213,13 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
195213 /// Allow filtering of suggestions as the user is typing.
196214 ///
197215 /// When `false` always show the full list of suggestions.
216+ /// Defaults to true.
198217 @Input ()
199218 bool filterSuggestions = true ;
200219
201220 /// Whether to close on enter even for string non matching options.
221+ ///
222+ /// Defaults to false.
202223 @Input ()
203224 bool closeOnEnter = false ;
204225
@@ -208,6 +229,8 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
208229
209230 /// Whether or not the suggestion popup width is at least as wide as the input
210231 /// width.
232+ ///
233+ /// Defaults to false.
211234 @Input ()
212235 bool popupMatchInputWidth = false ;
213236
@@ -231,6 +254,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
231254 /// Show or hide the trailing close icon.
232255 ///
233256 /// Clicking on the icon clears the input text and hides the popup.
257+ /// Defaults to false.
234258 @Input ()
235259 bool showClearIcon = false ;
236260
@@ -312,7 +336,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
312336 if (_cd != null ) {
313337 _cd.valueAccessor = this ;
314338 }
315- selection = _defaultSelection ;
339+ selection = SelectionModel . single () ;
316340 }
317341
318342 /// Publishes events when input text changes (on keypress.)
@@ -575,7 +599,7 @@ class MaterialAutoSuggestInputComponent extends MaterialSelectBase
575599 return false ;
576600 }
577601
578- if (selection != _defaultSelection &&
602+ if (shouldClearSelectionOnInput &&
579603 ! shouldClearOnSelection &&
580604 _lastSelectedItem != null ) {
581605 // deselect previously selected item as the component was not asked to
0 commit comments