feat: Introduce a generic inline rename input component for document editing

This commit is contained in:
2025-12-03 12:00:57 +01:00
parent e1dd1990d7
commit e66451afbd
5 changed files with 59 additions and 64 deletions
+14 -3
View File
@@ -62,11 +62,12 @@ const DesktopDocumentContainer: React.FC<React.ComponentProps<typeof DesktopDocu
onDeselect: (ids: string[]) => void;
onDocumentActivate?: (id: string, event?: any) => void;
selection: string[];
requestCanvasFocus?: () => void;
}> = React.memo((props) => {
const { layoutCard, selected, onSelect, onDeselect, onDocumentActivate, selection } = props;
const { layoutCard, selected, onSelect, onDeselect, onDocumentActivate, selection, requestCanvasFocus } = props;
// We assume layoutCard is always present in this context
const cardPointerHandlers = useCardPointer(layoutCard!, !!selected, selection, onSelect, onDeselect, onDocumentActivate);
const cardPointerHandlers = useCardPointer(layoutCard!, !!selected, selection, onSelect, onDeselect, onDocumentActivate, requestCanvasFocus);
return (
<DesktopDocumentCard
@@ -194,7 +195,11 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
}, [layoutStore.items]);
const handleShellKeyDown = useCallback(() => { }, []);
const focusShell = useCallback(() => { }, []);
const focusShell = useCallback(() => {
if (containerRef.current) {
containerRef.current.focus();
}
}, []);
// Tag Interactions
const tagInteractions = useDeskTagInteractions({
@@ -209,6 +214,11 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
useEffect(() => {
const handleWindowKeyDown = (e: KeyboardEvent) => {
// Only handle events if the container itself is the target (focused)
if (e.target !== containerRef.current) {
return;
}
// Space preview logic
if (e.code === 'Space' && selectedDocumentIds.length > 0) {
const lastId = selectedDocumentIds[selectedDocumentIds.length - 1];
@@ -422,6 +432,7 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
handleSelectionChange(Array.from(newSelection));
}}
selection={selectedDocumentIds}
requestCanvasFocus={focusShell}
/>
);
})}