fix(editor): opening a thread on a pristine composer crashed the app — give each Slate editor its own initial value
CI / Build & Quality Checks (push) Successful in 1m36s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 7s
CI / Trigger Desktop Build (push) Successful in 6s
CI / Playwright smoke (e2e) (push) Successful in 2m24s
CI / Build & Quality Checks (push) Successful in 1m36s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 7s
CI / Trigger Desktop Build (push) Successful in 6s
CI / Playwright smoke (e2e) (push) Successful in 2m24s
CustomEditor passed one module-level initialValue array to every <Slate>. slate-react keys its node→path weak maps by node identity, so mounting the thread composer re-mapped the shared nodes to the new editor and the main composer threw "Unable to find the path for Slate node" on its next render, taking the whole client to the error boundary. Anything that had already edited the main editor (typing, a restored draft) replaced its nodes and masked the bug, which is why it was intermittent. Reproduced with Playwright (fresh login → room → click "N replies"): crashed every time; typing one character first avoided it. Fixed by creating the initial value per instance (useState). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -23,7 +23,13 @@ import { CustomElement } from './slate';
|
||||
import * as css from './Editor.css';
|
||||
import { toggleKeyboardShortcut } from './keyboard';
|
||||
|
||||
const initialValue: CustomElement[] = [
|
||||
// One FRESH value per editor instance. slate-react keys its node→path weak
|
||||
// maps by node object identity, so a module-level constant shared by every
|
||||
// <Slate> (main composer + thread composer + message editor) makes the second
|
||||
// mount hijack the first editor's nodes and the first editor throws "Unable to
|
||||
// find the path for Slate node" on its next render — the app-wide crash when
|
||||
// opening a thread on a pristine composer (Gitea #165 / #184).
|
||||
const createInitialValue = (): CustomElement[] => [
|
||||
{
|
||||
type: BlockType.Paragraph,
|
||||
children: [{ text: '' }],
|
||||
@@ -92,6 +98,7 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const [initialValue] = useState(createInitialValue);
|
||||
const renderElement = useCallback(
|
||||
(props: RenderElementProps) => <RenderElement {...props} />,
|
||||
[],
|
||||
|
||||
Reference in New Issue
Block a user