@@ -3,7 +3,7 @@ import layout from '../templates/components/paper-tabs';
3
3
import { ParentMixin } from 'ember-composability-tools' ;
4
4
import ColorMixin from 'ember-paper/mixins/color-mixin' ;
5
5
6
- const { computed, Component, String : { htmlSafe } , inject } = Ember ;
6
+ const { computed, Component, String : { htmlSafe } , inject, observer } = Ember ;
7
7
8
8
export default Component . extend ( ParentMixin , ColorMixin , {
9
9
layout,
@@ -16,12 +16,22 @@ export default Component.extend(ParentMixin, ColorMixin, {
16
16
17
17
selected : 0 , // select first tab by default
18
18
19
- _selectedTab : computed ( 'childComponents.@each.value' , 'selected ', function ( ) {
20
- return this . get ( 'childComponents' ) . findBy ( 'value' , this . get ( 'selected' ) ) ;
19
+ _selectedTab : computed ( 'childComponents.@each.isSelected ' , function ( ) {
20
+ return this . get ( 'childComponents' ) . findBy ( 'isSelected' ) ;
21
21
} ) ,
22
22
23
- _previousSelectedTab :
computed ( '[email protected] ' , 'previousSelected' , function ( ) {
24
- return this . get ( 'childComponents' ) . findBy ( 'value' , this . get ( 'previousSelected' ) ) ;
23
+ _selectedTabDidChange : observer ( '_selectedTab' , function ( ) {
24
+ let selectedTab = this . get ( '_selectedTab' ) ;
25
+ let previousSelectedTab = this . get ( '_previousSelectedTab' ) ;
26
+
27
+ if ( selectedTab === previousSelectedTab ) {
28
+ return ;
29
+ }
30
+
31
+ this . setMovingRight ( ) ;
32
+ this . fixOffsetIfNeeded ( ) ;
33
+
34
+ this . set ( '_previousSelectedTab' , selectedTab ) ;
25
35
} ) ,
26
36
27
37
noInkBar : false ,
@@ -54,15 +64,6 @@ export default Component.extend(ParentMixin, ColorMixin, {
54
64
return ! this . get ( 'shouldPaginate' ) && this . get ( 'currentStretch' ) ;
55
65
} ) ,
56
66
57
- didReceiveAttrs ( ) {
58
- this . _super ( ...arguments ) ;
59
- if ( this . get ( 'selected' ) !== this . get ( 'previousSelected' ) ) {
60
- this . setMovingRight ( ) ;
61
- this . fixOffsetIfNeeded ( ) ;
62
- this . set ( 'previousSelected' , this . get ( 'selected' ) ) ;
63
- }
64
- } ,
65
-
66
67
didInsertElement ( ) {
67
68
this . _super ( ...arguments ) ;
68
69
0 commit comments