components/EditableTitle
import { … } from 'zidane-ui'ui/src/components/EditableTitle.tsx
Components#
EditableTitleComponent#
In-place rename surface for the session title. Uses contentEditable
so the editing affordance carries the title's exact typography
instead of swapping to an input chrome that breaks the row's optical
rhythm.
HTML pasting is sanitised at the onPaste seam — clipboard rich
text is converted to plain text before insertion, and newlines are
collapsed to spaces (a session title is a single line by contract).
contentEditable accepts HTML elements via drag-drop too; the
onInput handler reads textContent (not innerHTML) so any node
that sneaks in still lands as flat text on commit.
The element is uncontrolled while editing — React seeds the
textContent once on the false→true edit transition, then leaves
the DOM alone so the caret position survives each keystroke. The
parent's renameValue is kept in sync via onChange, so a commit that
reads it from a ref sees the current text.
function EditableTitle(props: EditableTitleProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | EditableTitleProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| display? | ReactNode | What shows instead of |
| editing | boolean | Whether the title is being edited in place. |
| label? | string | Accessible name of the editor (default: the |
| onCancel | () => void | Fired on Escape. |
| onChange | (value: string) => void | Fired on every keystroke while editing — keeps the parent's renameValue in sync. |
| onCommit | () => void | Promise<void> | Fired on blur or Enter; not on the blur that follows an Escape. |
| onStartEdit | () => void | Fired on double-click while not editing. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| text | string | Title shown when not editing AND the seed value when entering edit mode. |
Interfaces#
EditableTitlePropsInterface#
Props for EditableTitle.
interface EditableTitlePropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| display? | ReactNode | What shows instead of |
| editing | boolean | Whether the title is being edited in place. |
| label? | string | Accessible name of the editor (default: the |
| onCancel | () => void | Fired on Escape. |
| onChange | (value: string) => void | Fired on every keystroke while editing — keeps the parent's renameValue in sync. |
| onCommit | () => void | Promise<void> | Fired on blur or Enter; not on the blur that follows an Escape. |
| onStartEdit | () => void | Fired on double-click while not editing. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| text | string | Title shown when not editing AND the seed value when entering edit mode. |