Skip to content

Commit fa7ea0c

Browse files
committed
feat(split-pane): adds enabled input
fixes #10949
1 parent c72598a commit fa7ea0c

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/components/split-pane/split-pane.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ContentChildren, Directive, ElementRef, EventEmitter, forwardRef, Input, Output, QueryList, NgZone, Renderer } from '@angular/core';
22
import { Ion } from '../ion';
3-
import { assert } from '../../util/util';
3+
import { isTrueProperty, assert } from '../../util/util';
44
import { Config } from '../../config/config';
55
import { Platform } from '../../platform/platform';
66

@@ -142,9 +142,10 @@ export abstract class RootNode {
142142
})
143143
export class SplitPane extends Ion implements RootNode {
144144

145-
_rmListener: any;
146-
_visible: boolean = false;
147145
_init: boolean = false;
146+
_visible: boolean = false;
147+
_isEnabled: boolean = true;
148+
_rmListener: any;
148149
_mediaQuery: string | boolean = QUERY['md'];
149150
_children: RootNode[];
150151

@@ -190,6 +191,19 @@ export class SplitPane extends Ion implements RootNode {
190191
return this._mediaQuery;
191192
}
192193

194+
/**
195+
* @input {boolean} If `false`, the split-pane is disabled, ie. the side pane will
196+
* never be displayed. Default `true`.
197+
*/
198+
@Input()
199+
set enabled(val: boolean) {
200+
this._isEnabled = isTrueProperty(val);
201+
this._update();
202+
}
203+
get enabled(): boolean {
204+
return this._isEnabled;
205+
}
206+
193207
/**
194208
* @output {any} Expression to be called when the split-pane visibility has changed
195209
*/
@@ -247,6 +261,12 @@ export class SplitPane extends Ion implements RootNode {
247261
this._rmListener && this._rmListener();
248262
this._rmListener = null;
249263

264+
// Check if the split-pane is disabled
265+
if (!this._isEnabled) {
266+
this._setVisible(false);
267+
return;
268+
}
269+
250270
const query = this._mediaQuery;
251271
if (typeof query === 'boolean') {
252272
this._setVisible(query);

0 commit comments

Comments
 (0)