mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
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:
@@ -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
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user