@@ -162,7 +162,7 @@ export default Ember.Component.extend(
162162 }
163163 return this . _super ( ) ;
164164 } ,
165- updateDropdownLayout : Ember . observer ( function ( ) {
165+ updateDropdownLayout : Ember . observer ( 'showDropdown' , function ( ) {
166166 var dropdownButton , dropdownButtonHeight , dropdownButtonOffset , dropdownMargin , dropdownMenu , dropdownMenuBottom , dropdownMenuHeight , dropdownMenuOffset , dropdownMenuWidth , dropupMenuTop ;
167167 if ( ( this . get ( '_state' ) || this . get ( 'state' ) ) !== 'inDOM' || this . get ( 'showDropdown' ) === false ) {
168168 return ;
@@ -202,7 +202,7 @@ export default Ember.Component.extend(
202202 if ( highlightedIndex !== - 1 && this . get ( 'shouldEnsureVisible' ) ) {
203203 Ember . run . schedule ( 'afterRender' , ( ) => this . ensureVisible ( highlightedIndex ) ) ;
204204 }
205- } , 'showDropdown' ) ,
205+ } ) ,
206206 onResizeEnd : function ( ) {
207207 // We need to put this on the run loop, because the resize event came from
208208 // the window. Otherwise, we get a warning when used in the tests. You have
@@ -242,12 +242,12 @@ export default Ember.Component.extend(
242242 } ) ;
243243 } ) . property ( 'itemView' ) ,
244244
245- optionLabelPathChanges : Ember . on ( 'init' , Ember . observer ( function ( ) {
245+ optionLabelPathChanges : Ember . on ( 'init' , Ember . observer ( 'selection' , 'optionLabelPath' , function ( ) {
246246 var labelPath , path ;
247247 labelPath = this . get ( 'optionLabelPath' ) ;
248248 path = labelPath ? "selection." + labelPath : 'selection' ;
249249 return Ember . defineProperty ( this , 'selectedLabel' , Ember . computed . alias ( path ) ) ;
250- } , 'selection' , 'optionLabelPath' ) ) ,
250+ } ) ) ,
251251
252252 searchView : DebouncedTextComponent . extend ( {
253253 placeholder : Ember . computed . alias ( 'selectComponent.placeholder' ) ,
@@ -256,7 +256,7 @@ export default Ember.Component.extend(
256256 // this in a run loop to wait for the event that triggers the showDropdown
257257 // to finishes before trying to focus the input. Otherwise, focus when be
258258 // "stolen" from us.
259- showDropdownDidChange : Ember . observer ( function ( ) {
259+ showDropdownDidChange : Ember . observer ( 'selectComponent.showDropdown' , function ( ) {
260260 // when closing, don't need to focus the now-hidden search box
261261 if ( this . get ( 'selectComponent.showDropdown' ) ) {
262262 return Ember . run . schedule ( 'afterRender' , this , function ( ) {
@@ -269,7 +269,7 @@ export default Ember.Component.extend(
269269 this . set ( 'value' , '' ) ;
270270 this . get ( 'selectComponent' ) . send ( 'valueChanged' , '' ) ;
271271 }
272- } , 'selectComponent.showDropdown' ) ,
272+ } ) ,
273273
274274 /**
275275 Delegates to parent view (The select component) to propagate this data up.
@@ -394,22 +394,25 @@ export default Ember.Component.extend(
394394 contentIsEmpty : Ember . computed . empty ( 'content' ) ,
395395 hasNoResults : Ember . computed . and ( 'isLoaded' , 'filteredContentIsEmpty' ) ,
396396
397- value : Ember . computed ( function ( key , value ) {
398- var selection , valuePath , content ;
399- if ( arguments . length === 2 ) {
397+ value : Ember . computed ( 'selection' , {
398+ set ( key , value ) {
399+ var selection , valuePath , content ;
400400 valuePath = this . get ( 'optionValuePath' ) ;
401401 selection = value ;
402402 content = this . get ( 'content' ) ;
403403 if ( valuePath && content ) {
404- if ( typeof content . findProperty === 'function' ) {
405- selection = content . findProperty ( valuePath , value ) ;
404+ if ( typeof content . findBy === 'function' ) {
405+ selection = content . findBy ( valuePath , value ) ;
406406 } else {
407407 selection = find ( content , matchesProperty ( valuePath , value ) ) ;
408408 }
409409 }
410410 this . set ( 'selection' , selection ) ;
411411 return value ;
412- } else {
412+
413+ } ,
414+ get ( ) {
415+ var selection , valuePath ;
413416 valuePath = this . get ( 'optionValuePath' ) ;
414417 selection = this . get ( 'selection' ) ;
415418 if ( valuePath ) {
@@ -418,7 +421,7 @@ export default Ember.Component.extend(
418421 return selection ;
419422 }
420423 }
421- } ) . property ( 'selection' ) ,
424+ } ) ,
422425
423426 didInsertElement : function ( ) {
424427 this . _super ( ) ;
@@ -463,7 +466,7 @@ export default Ember.Component.extend(
463466 customFilter : null ,
464467
465468 // TODO(Peter): This needs to be rethought
466- setDefaultSelection : Ember . observer ( function ( ) {
469+ setDefaultSelection : Ember . observer ( 'content.[]' , function ( ) {
467470 var content , defaultPath ;
468471
469472 // do not set default selection if selection is defined
@@ -475,10 +478,10 @@ export default Ember.Component.extend(
475478 if ( ! ( content && defaultPath ) ) {
476479 return ;
477480 }
478- return this . set ( 'selection' , content . findProperty ( defaultPath ) ) ;
479- } , 'content.[]' ) ,
481+ return this . set ( 'selection' , content . findBy ( defaultPath ) ) ;
482+ } ) ,
480483
481- selectableOptionsDidChange : Ember . observer ( function ( ) {
484+ selectableOptionsDidChange : Ember . observer ( 'selectableOptions.[]' , 'showDropdown' , function ( ) {
482485 /*
483486 * If the dropdown is visible and the selected option is no longer
484487 * contained in the list of selectableOptions, then force the first
@@ -491,7 +494,7 @@ export default Ember.Component.extend(
491494 this . set ( 'highlighted' , selectableOptions . get ( 'firstObject' ) ) ;
492495 }
493496 }
494- } , 'selectableOptions.[]' , 'showDropdown' ) ,
497+ } ) ,
495498
496499 /*
497500 * SELECTION RELATED
@@ -520,23 +523,22 @@ export default Ember.Component.extend(
520523 shouldEnsureVisible : true ,
521524
522525 // The option that is currently highlighted.
523- highlighted : Ember . computed ( function ( key , value ) {
524- let content = this . get ( 'selectableOptions' ) || Ember . A ( ) ;
526+ highlighted : Ember . computed ( 'selectableOptions.[]' , 'highlightedIndex' , 'shouldEnsureVisible' , {
527+ set ( key , value ) {
528+ let content = this . get ( 'selectableOptions' ) || Ember . A ( ) ;
529+ let index = value ? content . indexOf ( value ) : - 1 ;
530+ this . setHighlightedIndex (
531+ index ,
532+ this . get ( 'shouldEnsureVisible' )
533+ ) ;
534+ return value || [ ] ;
525535
526- if ( arguments . length === 1 ) {
527- // Getter
536+ } ,
537+ get ( ) {
538+ let content = this . get ( 'selectableOptions' ) || Ember . A ( ) ;
528539 return content . objectAt ( this . get ( 'highlightedIndex' ) ) ;
529540 }
530-
531- // Setter
532- let index = value ? content . indexOf ( value ) : - 1 ;
533- this . setHighlightedIndex (
534- index ,
535- this . get ( 'shouldEnsureVisible' )
536- ) ;
537- return value || [ ] ;
538-
539- } ) . property ( 'selectableOptions.[]' , 'highlightedIndex' , 'shouldEnsureVisible' ) ,
541+ } ) ,
540542
541543 setFocus : function ( ) {
542544 var activeElem , selectComponent ;
0 commit comments