Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(react): owned attributes not showing up the first time
Elian Doran40e4d236f49a
diff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsxindex 9c60845417..848a760e22 100644--- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx+++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx@@ -83,12 +83,13 @@ interface AttributeEditorProps {}export default function AttributeEditor({ note, componentId, notePath, ntxId, hidden }: AttributeEditorProps) {+ const [ currentValue, setCurrentValue ] = useState("");const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();const [ error, setError ] = useState<unknown>();const [ needsSaving, setNeedsSaving ] = useState(false);const lastSavedContent = useRef<string>();- const currentValueRef = useRef("");+ const currentValueRef = useRef(currentValue);const wrapperRef = useRef<HTMLDivElement>(null);const editorRef = useRef<CKEditorApi>();@@ -126,6 +127,7 @@ export default function AttributeEditor({ note, componentId, notePath, ntxId, hi}editorRef.current?.setText(htmlAttrs);+ setCurrentValue(htmlAttrs);}function parseAttributes() {@@ -289,7 +291,7 @@ export default function AttributeEditor({ note, componentId, notePath, ntxId, hiclassName="attribute-list-editor"tabIndex={200}editor={CKEditorAttributeEditor}- currentValue="" // handled imperatively+ currentValue={currentValue}config={{toolbar: { items: [] },placeholder: t("attribute_editor.placeholder"),