Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/cdk-experimental/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class CdkListbox<V> {
host: {
'role': 'option',
'class': 'cdk-option',
'[class.cdk-active]': 'pattern.active()',
'[attr.tabindex]': 'pattern.tabindex()',
'[attr.aria-selected]': 'pattern.selected()',
'[attr.aria-disabled]': 'pattern.disabled()',
Expand Down
3 changes: 3 additions & 0 deletions src/cdk-experimental/ui-patterns/listbox/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export class OptionPattern<V> {
.findIndex(i => i.id() === this.id()) ?? -1,
);

/** Whether the option is active. */
active = computed(() => this.listbox()?.focusManager.activeItem() === this);

/** Whether the option is selected. */
selected = computed(() => this.listbox()?.selection.inputs.value().includes(this.value()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
border-radius: var(--mat-sys-corner-extra-small);
}

.example-option[aria-disabled='false']:hover,
.example-option[tabindex='0'] {
.example-option.cdk-active,
.example-option[aria-disabled='false']:hover {
outline: 1px solid var(--mat-sys-outline);
background: var(--mat-sys-surface-container);
}
Expand All @@ -61,8 +61,8 @@
background-color: var(--mat-sys-secondary-container);
}

.example-option[aria-disabled='true']:focus-within,
.example-option[aria-disabled='true'][tabindex='0'] {
.example-option.cdk-active[aria-disabled='true'],
.example-option[aria-disabled='true']:focus-within {
outline: 2px solid var(--mat-sys-outline);
}

Expand Down
Loading