Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/aria/private/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,6 @@ export class ToolbarPattern<V> {
setDefaultState(): void;
readonly softDisabled: SignalLike<boolean>;
readonly tabIndex: SignalLike<0 | -1>;
validate(): string[];
}

// @public
Expand Down Expand Up @@ -918,6 +917,7 @@ export class TreePattern<V> implements TreeInputs<V> {
readonly treeBehavior: Tree<TreeItemPattern<V>, V>;
readonly typeaheadDelay: SignalLike<number>;
readonly typeaheadRegexp: RegExp;
validate(): string[];
readonly values: WritableSignalLike<V[]>;
readonly visible: () => boolean;
readonly wrap: SignalLike<boolean>;
Expand Down
6 changes: 0 additions & 6 deletions src/aria/private/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,4 @@ export class ToolbarPattern<V> {
this.inputs.activeItem.set(firstItem);
}
}

/** Validates the state of the toolbar and returns a list of accessibility violations. */
validate(): string[] {
const violations: string[] = [];
return violations;
}
}
13 changes: 13 additions & 0 deletions src/aria/private/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,19 @@ export class TreePattern<V> implements TreeInputs<V> {
});
}

/** Returns a set of violations */
validate(): string[] {
const violations: string[] = [];

if (!this.inputs.multi() && this.inputs.values().length > 1) {
violations.push(
`A single-select tree should not have multiple selected options. Selected options: ${this.inputs.values().join(', ')}`,
);
}

return violations;
}

/**
* Sets the tree to it's default initial state.
*
Expand Down
9 changes: 0 additions & 9 deletions src/aria/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ export class Toolbar<V> {
private _hasBeenFocused = signal(false);

constructor() {
afterRenderEffect(() => {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
const violations = this._pattern.validate();
for (const violation of violations) {
console.error(violation);
}
}
});

afterRenderEffect(() => {
if (!this._hasBeenFocused()) {
this._pattern.setDefaultState();
Expand Down
9 changes: 9 additions & 0 deletions src/aria/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ export class Tree<V> {
this._popup?._controls?.set(this._pattern as ComboboxTreePattern<V>);
}

afterRenderEffect(() => {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
const violations = this._pattern.validate();
for (const violation of violations) {
console.error(violation);
}
}
});

afterRenderEffect(() => {
if (!this._hasFocused()) {
this._pattern.setDefaultState();
Expand Down
Loading