@@ -22,7 +22,7 @@ import { SidebarBackdropService } from '../sidebar-backdrop/sidebar-backdrop.ser
22
22
@Component ( {
23
23
selector : 'c-sidebar' ,
24
24
exportAs : 'cSidebar' ,
25
- template : '<ng-content></ng-content>' ,
25
+ template : '<ng-content></ng-content>'
26
26
} )
27
27
export class SidebarComponent implements OnChanges , OnDestroy , OnInit {
28
28
@@ -58,6 +58,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
58
58
set narrow ( value : boolean ) {
59
59
this . _narrow = coerceBooleanProperty ( value ) ;
60
60
}
61
+
61
62
get narrow ( ) {
62
63
return this . _narrow ;
63
64
}
@@ -70,6 +71,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
70
71
set overlaid ( value : boolean ) {
71
72
this . _overlaid = coerceBooleanProperty ( value ) ;
72
73
}
74
+
73
75
get overlaid ( ) {
74
76
return this . _overlaid ;
75
77
}
@@ -92,6 +94,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
92
94
set unfoldable ( value : boolean ) {
93
95
this . _unfoldable = coerceBooleanProperty ( value ) ;
94
96
}
97
+
95
98
get unfoldable ( ) {
96
99
return this . _unfoldable ;
97
100
}
@@ -101,9 +104,13 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
101
104
*/
102
105
@Input ( )
103
106
set visible ( value : boolean ) {
104
- this . _visible = coerceBooleanProperty ( value ) ;
105
- this . visibleChange . emit ( this . _visible ) ;
107
+ const visible = coerceBooleanProperty ( value ) ;
108
+ if ( this . _visible !== visible ) {
109
+ this . _visible = visible ;
110
+ this . visibleChange . emit ( this . _visible ) ;
111
+ }
106
112
}
113
+
107
114
get visible ( ) {
108
115
return this . _visible ;
109
116
}
@@ -124,6 +131,8 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
124
131
newState . unfoldable = ! this . state . unfoldable ;
125
132
this . unfoldable = newState . unfoldable ;
126
133
}
134
+ } else {
135
+ this . visible = ( newState . visible ?? this . visible ) && ! this . overlaid ;
127
136
}
128
137
this . state = {
129
138
...this . state ,
@@ -155,12 +164,12 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
155
164
156
165
@HostBinding ( 'class' )
157
166
get getClasses ( ) : any {
158
- const { mobile, unfoldable, visible} = this . sidebarState ;
167
+ const { mobile, unfoldable, visible } = this . sidebarState ;
159
168
return {
160
169
sidebar : true ,
161
170
'sidebar-fixed' : this . position === 'fixed' && ! mobile ,
162
171
'sidebar-narrow' : this . narrow && ! this . unfoldable ,
163
- 'sidebar-narrow-unfoldable' : unfoldable ,
172
+ 'sidebar-narrow-unfoldable' : this . unfoldable ,
164
173
'sidebar-overlaid' : this . overlaid ,
165
174
[ `sidebar-${ this . size } ` ] : ! ! this . size ,
166
175
show : visible && this . onMobile ,
@@ -232,12 +241,13 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
232
241
233
242
this . layoutChangeSubscription = layoutChanges . subscribe ( ( result : BreakpointState ) => {
234
243
const isOnMobile = result . breakpoints [ onMobile ] ;
244
+ const isUnfoldable = isOnMobile ? false : this . unfoldable ;
235
245
if ( this . onMobile !== isOnMobile ) {
236
246
this . onMobile = isOnMobile ;
237
247
this . sidebarService . toggle ( {
238
248
mobile : isOnMobile ,
239
- unfoldable : isOnMobile ? false : this . unfoldable ,
240
- visible : isOnMobile ? false : this . visible ,
249
+ unfoldable : isUnfoldable ,
250
+ visible : ( ! isOnMobile ) || isUnfoldable ,
241
251
sidebar : this
242
252
} ) ;
243
253
}
0 commit comments