This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
src/components/autocomplete Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,29 @@ describe('<md-autocomplete>', function() {
163
163
element . remove ( ) ;
164
164
} ) ) ;
165
165
166
+ it ( 'should forward the `md-select-on-focus` attribute to the input' , inject ( function ( ) {
167
+ var scope = createScope ( null , { inputId : 'custom-input-id' } ) ;
168
+ var template =
169
+ '<md-autocomplete ' +
170
+ 'md-input-id="{{inputId}}" ' +
171
+ 'md-selected-item="selectedItem" ' +
172
+ 'md-search-text="searchText" ' +
173
+ 'md-items="item in match(searchText)" ' +
174
+ 'md-item-text="item.display" ' +
175
+ 'md-select-on-focus="" ' +
176
+ 'tabindex="3"' +
177
+ 'placeholder="placeholder">' +
178
+ '<span md-highlight-text="searchText">{{item.display}}</span>' +
179
+ '</md-autocomplete>' ;
180
+
181
+ var element = compile ( template , scope ) ;
182
+ var input = element . find ( 'input' ) ;
183
+
184
+ expect ( input . attr ( 'md-select-on-focus' ) ) . toBe ( "" ) ;
185
+
186
+ element . remove ( ) ;
187
+ } ) ) ;
188
+
166
189
it ( 'should forward the tabindex to the input' , inject ( function ( ) {
167
190
var scope = createScope ( null , { inputId : 'custom-input-id' } ) ;
168
191
var template =
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ angular
58
58
* `md-input-container`
59
59
* @param {string= } md-input-name The name attribute given to the input element to be used with
60
60
* FormController
61
+ * @param {string= } md-select-on-focus When present the inputs text will be automatically selected
62
+ * on focus.
61
63
* @param {string= } md-input-id An ID to be added to the input element
62
64
* @param {number= } md-input-minlength The minimum length for the input's value for validation
63
65
* @param {number= } md-input-maxlength The maximum length for the input's value for validation
@@ -243,6 +245,7 @@ function MdAutocomplete () {
243
245
ng-blur="$mdAutocompleteCtrl.blur()"\
244
246
ng-focus="$mdAutocompleteCtrl.focus()"\
245
247
aria-owns="ul-{{$mdAutocompleteCtrl.id}}"\
248
+ ' + ( attr . mdSelectOnFocus != null ? 'md-select-on-focus=""' : '' ) + '\
246
249
aria-label="{{floatingLabel}}"\
247
250
aria-autocomplete="list"\
248
251
aria-haspopup="true"\
@@ -266,6 +269,7 @@ function MdAutocomplete () {
266
269
ng-focus="$mdAutocompleteCtrl.focus()"\
267
270
placeholder="{{placeholder}}"\
268
271
aria-owns="ul-{{$mdAutocompleteCtrl.id}}"\
272
+ ' + ( attr . mdSelectOnFocus != null ? 'md-select-on-focus=""' : '' ) + '\
269
273
aria-label="{{placeholder}}"\
270
274
aria-autocomplete="list"\
271
275
aria-haspopup="true"\
You can’t perform that action at this time.
0 commit comments