File tree Expand file tree Collapse file tree 5 files changed +23
-16
lines changed
Expand file tree Collapse file tree 5 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -781,7 +781,6 @@ export class ToolbarPattern<V> {
781781 setDefaultState(): void ;
782782 readonly softDisabled: SignalLike <boolean >;
783783 readonly tabIndex: SignalLike <0 | -1 >;
784- validate(): string [];
785784}
786785
787786// @public
@@ -918,6 +917,7 @@ export class TreePattern<V> implements TreeInputs<V> {
918917 readonly treeBehavior: Tree <TreeItemPattern <V >, V >;
919918 readonly typeaheadDelay: SignalLike <number >;
920919 readonly typeaheadRegexp: RegExp ;
920+ validate(): string [];
921921 readonly values: WritableSignalLike <V []>;
922922 readonly visible: () => boolean ;
923923 readonly wrap: SignalLike <boolean >;
Original file line number Diff line number Diff line change @@ -198,10 +198,4 @@ export class ToolbarPattern<V> {
198198 this . inputs . activeItem . set ( firstItem ) ;
199199 }
200200 }
201-
202- /** Validates the state of the toolbar and returns a list of accessibility violations. */
203- validate ( ) : string [ ] {
204- const violations : string [ ] = [ ] ;
205- return violations ;
206- }
207201}
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 @@ -109,15 +109,6 @@ export class Toolbar<V> {
109109 private _hasBeenFocused = signal ( false ) ;
110110
111111 constructor ( ) {
112- afterRenderEffect ( ( ) => {
113- if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
114- const violations = this . _pattern . validate ( ) ;
115- for ( const violation of violations ) {
116- console . error ( violation ) ;
117- }
118- }
119- } ) ;
120-
121112 afterRenderEffect ( ( ) => {
122113 if ( ! this . _hasBeenFocused ( ) ) {
123114 this . _pattern . setDefaultState ( ) ;
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