fix: allow typing spaces in session rename input

The @dnd-kit KeyboardSensor intercepts the Space key globally to
activate drag-and-drop, preventing spaces from being typed in the
session rename input field. Use a custom KeyboardSensor that skips
activation when the event target is an input, textarea, or
contenteditable element.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
yushen
2026-02-04 17:37:14 +08:00
parent 19a556359e
commit d4c1790bda

View File

@@ -29,6 +29,31 @@ import {
verticalListSortingStrategy
} from '@dnd-kit/sortable'
// Custom KeyboardSensor that doesn't intercept keyboard events from input fields.
// The default KeyboardSensor uses Space to activate drag, which prevents typing
// spaces in the session rename input.
class SidebarKeyboardSensor extends KeyboardSensor {
static activators = [
{
eventName: 'onKeyDown' as const,
handler: (
...args: Parameters<(typeof KeyboardSensor.activators)[0]['handler']>
): boolean | undefined => {
const [event] = args
const target = event.target as HTMLElement
if (
target.tagName === 'INPUT' ||
target.tagName === 'TEXTAREA' ||
target.isContentEditable
) {
return false
}
return KeyboardSensor.activators[0].handler(...args)
}
}
] as (typeof KeyboardSensor)['activators']
}
interface AppSidebarProps {
projects: MulticaProject[]
sessionsByProject: Map<string, MulticaSession[]>
@@ -65,7 +90,7 @@ export function AppSidebar({
distance: 8 // Require 8px movement to start drag
}
}),
useSensor(KeyboardSensor, {
useSensor(SidebarKeyboardSensor, {
coordinateGetter: sortableKeyboardCoordinates
})
)