fix(react): owned attributes not showing up the first time

This commit is contained in:
Elian Doran 2025-08-27 17:42:38 +03:00
parent 0450cd080d
commit 40e4d236f4
No known key found for this signature in database

View File

@ -83,12 +83,13 @@ interface AttributeEditorProps {
} }
export default function AttributeEditor({ note, componentId, notePath, ntxId, hidden }: AttributeEditorProps) { export default function AttributeEditor({ note, componentId, notePath, ntxId, hidden }: AttributeEditorProps) {
const [ currentValue, setCurrentValue ] = useState("");
const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">(); const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();
const [ error, setError ] = useState<unknown>(); const [ error, setError ] = useState<unknown>();
const [ needsSaving, setNeedsSaving ] = useState(false); const [ needsSaving, setNeedsSaving ] = useState(false);
const lastSavedContent = useRef<string>(); const lastSavedContent = useRef<string>();
const currentValueRef = useRef(""); const currentValueRef = useRef(currentValue);
const wrapperRef = useRef<HTMLDivElement>(null); const wrapperRef = useRef<HTMLDivElement>(null);
const editorRef = useRef<CKEditorApi>(); const editorRef = useRef<CKEditorApi>();
@ -126,6 +127,7 @@ export default function AttributeEditor({ note, componentId, notePath, ntxId, hi
} }
editorRef.current?.setText(htmlAttrs); editorRef.current?.setText(htmlAttrs);
setCurrentValue(htmlAttrs);
} }
function parseAttributes() { function parseAttributes() {
@ -289,7 +291,7 @@ export default function AttributeEditor({ note, componentId, notePath, ntxId, hi
className="attribute-list-editor" className="attribute-list-editor"
tabIndex={200} tabIndex={200}
editor={CKEditorAttributeEditor} editor={CKEditorAttributeEditor}
currentValue="" // handled imperatively currentValue={currentValue}
config={{ config={{
toolbar: { items: [] }, toolbar: { items: [] },
placeholder: t("attribute_editor.placeholder"), placeholder: t("attribute_editor.placeholder"),