interface InlineEditFieldProps
extends Pick<
"value" | "kind" | "required" | "maxLength" | "placeholder"
>

Passed to InlineEditField by InlineEdit, and by the components that open it with an action of their own, CommentNode and ChatMessageItem, in place of the text while it is edited.

Properties

onSave: (value: string) => Promise<void> | void

Saves the trimmed text. The field closes once it is done, and stays open under the error it throws. A text left as it was isn't passed to it.

onClose: () => void

Called once the text is saved, or left: the field is to unmount.

optional
label: string

Names a one-line field, such as "Edit title".

optional
fieldClassName: string

Added to the field: for a one-line one, the class of the text it edits, such as dump-title, so that it takes on its type in every style.

optional
enterSaves: boolean

In the Markdown editor, saves on Enter, a line breaking on Shift+Enter, as the chat's composer does. Ctrl/Cmd+Enter saves in either case.

optional
countFrom: number

Where the Markdown editor's counter starts, near maxLength.

optional
returnFocusTo: React.RefObject<HTMLElement | null>

Takes the focus once the field is gone, if it had it and no one has taken it since: the button that opened it, back in its place.

Usage

import { type InlineEditFieldProps } from "src/components/form/InlineEdit.tsx";