Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const CellWidget: FC<EditorCellProps> = ({
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)

Expand Down Expand Up @@ -248,6 +248,10 @@ export const CellWidget: FC<EditorCellProps> = ({
value={enumValue.join(', ')}
isInherited={isInherited}
columnId={columnId}
cellId={cellId}
onRequestEdit={setEditingCellId}
getDraftValue={getEditingDraft}
setDraftValue={setEditingDraft}
{...sharedProps}
{...pt?.text}
/>
Expand Down Expand Up @@ -285,6 +289,9 @@ export const CellWidget: FC<EditorCellProps> = ({
columnId={columnId}
cellId={cellId}
type={type as TextWidgetType}
onRequestEdit={setEditingCellId}
getDraftValue={getEditingDraft}
setDraftValue={setEditingDraft}
{...sharedProps}
{...pt?.text}
/>
Expand Down
20 changes: 14 additions & 6 deletions shared/src/containers/ProjectTreeTable/widgets/TextWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ──────────────────────────────────────────────

Expand Down Expand Up @@ -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<HTMLSpanElement, TextWidgetProps>(
Expand All @@ -159,12 +162,17 @@ export const TextWidget = forwardRef<HTMLSpanElement, TextWidgetProps>(
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)
Expand Down Expand Up @@ -285,8 +293,8 @@ export const TextWidget = forwardRef<HTMLSpanElement, TextWidgetProps>(
// ── 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.
Expand Down Expand Up @@ -432,8 +440,8 @@ export const TextWidget = forwardRef<HTMLSpanElement, TextWidgetProps>(
onChange={handleDescriptionChange}
onCancelEdit={onCancelEdit}
onDismissWithoutSave={onCancelEdit}
draftValue={getEditingDraft()}
onEditingDraftChange={setEditingDraft}
draftValue={getCurrentDraft()}
onEditingDraftChange={setCurrentDraft}
/>
)}

Expand Down
Loading