Skip to content

Commit 181d577

Browse files
committed
fixup! feat(cdk-experimental/listbox): readonly mode
1 parent 7166610 commit 181d577

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/cdk-experimental/listbox/listbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {_IdGenerator} from '@angular/cdk/a11y';
4242
'role': 'listbox',
4343
'class': 'cdk-listbox',
4444
'[attr.tabindex]': 'pattern.tabindex()',
45+
'[attr.aria-readonly]': 'pattern.readonly()',
4546
'[attr.aria-disabled]': 'pattern.disabled()',
4647
'[attr.aria-orientation]': 'pattern.orientation()',
4748
'[attr.aria-multiselectable]': 'pattern.multi()',

src/cdk-experimental/ui-patterns/listbox/listbox.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ export class ListboxPattern<V> {
5757
/** Whether the listbox is disabled. */
5858
disabled: SignalLike<boolean>;
5959

60+
/** Whether the listbox is readonly. */
61+
readonly: SignalLike<boolean>;
62+
6063
/** The tabindex of the listbox. */
6164
tabindex = computed(() => this.focusManager.getListTabindex());
6265

@@ -95,7 +98,7 @@ export class ListboxPattern<V> {
9598
keydown = computed(() => {
9699
const manager = new KeyboardEventManager();
97100

98-
if (this.inputs.readonly()) {
101+
if (this.readonly()) {
99102
return manager
100103
.on(this.prevKey, () => this.prev())
101104
.on(this.nextKey, () => this.next())
@@ -160,8 +163,8 @@ export class ListboxPattern<V> {
160163
pointerdown = computed(() => {
161164
const manager = new PointerEventManager();
162165

163-
if (this.inputs.readonly()) {
164-
manager.on(e => this.goto(e));
166+
if (this.readonly()) {
167+
return manager.on(e => this.goto(e));
165168
}
166169

167170
if (this.inputs.multi()) {
@@ -175,6 +178,7 @@ export class ListboxPattern<V> {
175178

176179
constructor(readonly inputs: ListboxInputs<V>) {
177180
this.disabled = inputs.disabled;
181+
this.readonly = inputs.readonly;
178182
this.orientation = inputs.orientation;
179183
this.multi = inputs.multi;
180184

0 commit comments

Comments
 (0)