File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -780,7 +780,6 @@ export class ToolbarPattern<V> {
780780 setDefaultState(): void ;
781781 readonly softDisabled: SignalLike <boolean >;
782782 readonly tabIndex: SignalLike <0 | -1 >;
783- validate(): string [];
784783}
785784
786785// @public
@@ -917,6 +916,7 @@ export class TreePattern<V> implements TreeInputs<V> {
917916 readonly treeBehavior: Tree <TreeItemPattern <V >, V >;
918917 readonly typeaheadDelay: SignalLike <number >;
919918 readonly typeaheadRegexp: RegExp ;
919+ validate(): string [];
920920 readonly values: WritableSignalLike <V []>;
921921 readonly visible: () => boolean ;
922922 readonly wrap: SignalLike <boolean >;
Original file line number Diff line number Diff line change @@ -358,6 +358,19 @@ export class TreePattern<V> implements TreeInputs<V> {
358358 } ) ;
359359 }
360360
361+ /** Returns a set of violations */
362+ validate ( ) : string [ ] {
363+ const violations : string [ ] = [ ] ;
364+
365+ if ( ! this . inputs . multi ( ) && this . inputs . values ( ) . length > 1 ) {
366+ violations . push (
367+ `A single-select tree should not have multiple selected options. Selected options: ${ this . inputs . values ( ) . join ( ', ' ) } ` ,
368+ ) ;
369+ }
370+
371+ return violations ;
372+ }
373+
361374 /**
362375 * Sets the tree to it's default initial state.
363376 *
Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ export class Tree<V> {
174174 this . _popup ?. _controls ?. set ( this . _pattern as ComboboxTreePattern < V > ) ;
175175 }
176176
177+ afterRenderEffect ( ( ) => {
178+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
179+ const violations = this . _pattern . validate ( ) ;
180+ for ( const violation of violations ) {
181+ console . error ( violation ) ;
182+ }
183+ }
184+ } ) ;
185+
177186 afterRenderEffect ( ( ) => {
178187 if ( ! this . _hasFocused ( ) ) {
179188 this . _pattern . setDefaultState ( ) ;
You can’t perform that action at this time.
0 commit comments