Skip to content

Commit 1a1b65c

Browse files
committed
fix: chat list multiselect: treat Meta key as Ctrl
1 parent 0dfedf3 commit 1a1b65c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/frontend/src/hooks/useMultiselect.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ export function useMultiselect<T>(
205205
// but not on `FocusEvent`. This is why we need to track them here.
206206
const shiftPressed = useRef(false)
207207
const ctrlPressed = useRef(false)
208+
const metaPressed = useRef(false)
208209
useEffect(() => {
209210
const onEvent = (ev: KeyboardEvent | MouseEvent) => {
210211
shiftPressed.current = ev.shiftKey
211212
ctrlPressed.current = ev.ctrlKey
213+
metaPressed.current = ev.metaKey
212214
}
213215
document.addEventListener('keydown', onEvent, { passive: true })
214216
document.addEventListener('keyup', onEvent, { passive: true })
@@ -233,7 +235,7 @@ export function useMultiselect<T>(
233235
// but let's not do that, e.g. in case we later actually need it,
234236
// and also because `event.ctrlKey` is a more reliable
235237
// "source of truth" than our custom `ctrlPressed` tracking code.
236-
if (event.ctrlKey) {
238+
if (event.ctrlKey || event.metaKey) {
237239
toggleItemSelection(item)
238240
lastActivatedItem.current = item
239241
return true // shouldPreventDefault
@@ -258,7 +260,7 @@ export function useMultiselect<T>(
258260
if (shiftPressed.current) {
259261
onSelectContiguous(item)
260262
} else {
261-
if (!ctrlPressed.current) {
263+
if (!(ctrlPressed.current || metaPressed.current)) {
262264
// This is to make sure that a sequence
263265
// ArrowDown
264266
// ArrowDown

0 commit comments

Comments
 (0)