Skip to content

Commit 722b81b

Browse files
committed
fixup! feat(cdk-experimental/ui-patterns): listbox ui pattern
1 parent b01fb41 commit 722b81b

File tree

1 file changed

+8
-13
lines changed
  • src/cdk-experimental/ui-patterns/listbox

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export class ListboxPattern {
113113
if (this.inputs.multiselectable()) {
114114
manager
115115
.on(Modifier.Shift, ' ', () => this._updateSelection({selectFromAnchor: true}))
116+
.on(Modifier.Shift, 'Enter', () => this._updateSelection({selectFromAnchor: true}))
116117
.on(Modifier.Shift, this.prevKey, () => this.prev({toggle: true}))
117118
.on(Modifier.Shift, this.nextKey, () => this.next({toggle: true}))
118119
.on(Modifier.Ctrl | Modifier.Shift, 'Home', () => this.first({selectFromActive: true}))
@@ -122,10 +123,12 @@ export class ListboxPattern {
122123

123124
if (!this.followFocus() && this.inputs.multiselectable()) {
124125
manager.on(' ', () => this._updateSelection({toggle: true}));
126+
manager.on('Enter', () => this._updateSelection({toggle: true}));
125127
}
126128

127129
if (!this.followFocus() && !this.inputs.multiselectable()) {
128130
manager.on(' ', () => this._updateSelection({toggleOne: true}));
131+
manager.on('Enter', () => this._updateSelection({toggleOne: true}));
129132
}
130133

131134
if (this.inputs.multiselectable() && this.followFocus()) {
@@ -143,20 +146,12 @@ export class ListboxPattern {
143146
pointerdown = computed(() => {
144147
const manager = new PointerEventManager();
145148

146-
if (!this.followFocus()) {
147-
manager.on((e: PointerEvent) => this.goto(e));
148-
}
149-
150-
if (this.followFocus()) {
151-
manager.on((e: PointerEvent) => this.goto(e, {selectOne: true}));
152-
}
153-
154-
if (this.inputs.multiselectable() && this.followFocus()) {
155-
manager.on(Modifier.Ctrl, (e: PointerEvent) => this.goto(e));
156-
}
157-
158149
if (this.inputs.multiselectable()) {
159-
manager.on(Modifier.Shift, (e: PointerEvent) => this.goto(e, {selectFromActive: true}));
150+
manager
151+
.on(e => this.goto(e, {toggle: true}))
152+
.on(Modifier.Shift, e => this.goto(e, {selectFromActive: true}));
153+
} else {
154+
manager.on(e => this.goto(e, {toggleOne: true}));
160155
}
161156

162157
return manager;

0 commit comments

Comments
 (0)