diff --git a/shared/src/containers/ProjectTreeTable/widgets/CellWidget.tsx b/shared/src/containers/ProjectTreeTable/widgets/CellWidget.tsx index 18d147924..3f429df3d 100644 --- a/shared/src/containers/ProjectTreeTable/widgets/CellWidget.tsx +++ b/shared/src/containers/ProjectTreeTable/widgets/CellWidget.tsx @@ -115,7 +115,7 @@ export const CellWidget: FC = ({ const type = attributeData?.type const { projectName } = useProjectContext() - const { isEditing, setEditingCellId } = useCellEditing() + const { isEditing, setEditingCellId, getEditingDraft, setEditingDraft } = useCellEditing() const { isCellFocused, gridMap, selectCell, focusCell } = useSelectionCellsContext() const cellId = getCellId(rowId, columnId) @@ -248,6 +248,10 @@ export const CellWidget: FC = ({ value={enumValue.join(', ')} isInherited={isInherited} columnId={columnId} + cellId={cellId} + onRequestEdit={setEditingCellId} + getDraftValue={getEditingDraft} + setDraftValue={setEditingDraft} {...sharedProps} {...pt?.text} /> @@ -285,6 +289,9 @@ export const CellWidget: FC = ({ columnId={columnId} cellId={cellId} type={type as TextWidgetType} + onRequestEdit={setEditingCellId} + getDraftValue={getEditingDraft} + setDraftValue={setEditingDraft} {...sharedProps} {...pt?.text} /> diff --git a/shared/src/containers/ProjectTreeTable/widgets/TextWidget.tsx b/shared/src/containers/ProjectTreeTable/widgets/TextWidget.tsx index 4ec5c015e..e6d80608b 100644 --- a/shared/src/containers/ProjectTreeTable/widgets/TextWidget.tsx +++ b/shared/src/containers/ProjectTreeTable/widgets/TextWidget.tsx @@ -12,7 +12,7 @@ import clsx from 'clsx' import { parseHtmlToPlainTextWithLinks } from '@shared/util' import { TextContentWidget } from './TextContentWidget' import { CellEditingDialog } from '@shared/components/LinksManager/CellEditingDialog' -import { useCellEditing } from '../context/CellEditingContext' +import { CellId } from '../utils/cellUtils' // ── Styled components ────────────────────────────────────────────── @@ -144,6 +144,9 @@ export interface TextWidgetProps type?: TextWidgetType columnId?: string cellId?: string + onRequestEdit?: (id: CellId | null) => void + getDraftValue?: () => string | null + setDraftValue?: (value: string | null) => void } export const TextWidget = forwardRef( @@ -159,12 +162,17 @@ export const TextWidget = forwardRef( type, columnId, cellId, + onRequestEdit, + getDraftValue, + setDraftValue, className, ...props }, ref, ) => { - const { setEditingCellId, getEditingDraft, setEditingDraft } = useCellEditing() + const requestEdit = onRequestEdit || (() => undefined) + const getCurrentDraft = getDraftValue || (() => null) + const setCurrentDraft = setDraftValue || (() => undefined) const [isHoveredOnCell, setIsHoveredOnCell] = useState(false) const [isHoveredOnPreview, setIsHoveredOnPreview] = useState(false) @@ -285,8 +293,8 @@ export const TextWidget = forwardRef( // ── Preview click → start editing const handlePreviewClick = useCallback(() => { updatePreview(false) - if (cellId) setEditingCellId(cellId) - }, [cellId, setEditingCellId, updatePreview]) + if (cellId) requestEdit(cellId) + }, [cellId, requestEdit, updatePreview]) // For description columns, Ctrl+Enter should save and close — not jump to next row. // Remap 'Enter' → 'Click' so CellWidget doesn't call moveToNextRow. @@ -432,8 +440,8 @@ export const TextWidget = forwardRef( onChange={handleDescriptionChange} onCancelEdit={onCancelEdit} onDismissWithoutSave={onCancelEdit} - draftValue={getEditingDraft()} - onEditingDraftChange={setEditingDraft} + draftValue={getCurrentDraft()} + onEditingDraftChange={setCurrentDraft} /> )}