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
chore(status_bar): fix inherited attribute key and useEffect deps
Elian Doranad3cdc3364aa
diff --git a/apps/client/src/widgets/ribbon/InheritedAttributesTab.tsx b/apps/client/src/widgets/ribbon/InheritedAttributesTab.tsxindex ee8b87c6b0..fcee7c1da1 100644--- a/apps/client/src/widgets/ribbon/InheritedAttributesTab.tsx+++ b/apps/client/src/widgets/ribbon/InheritedAttributesTab.tsx@@ -1,17 +1,18 @@import { useEffect, useState } from "preact/hooks";-import { TabContext } from "./ribbon-interface";+import FAttribute from "../../entities/fattribute";-import { useLegacyWidget, useTriliumEvent } from "../react/hooks";+import attribute_renderer from "../../services/attribute_renderer";import attributes from "../../services/attributes";import { t } from "../../services/i18n";-import attribute_renderer from "../../services/attribute_renderer";+import AttributeDetailWidget from "../attribute_widgets/attribute_detail";+import { useLegacyWidget, useTriliumEvent } from "../react/hooks";import RawHtml from "../react/RawHtml";import { joinElements } from "../react/react_utils";-import AttributeDetailWidget from "../attribute_widgets/attribute_detail";+import { TabContext } from "./ribbon-interface";type InheritedAttributesTabArgs = Pick<TabContext, "note" | "componentId"> & {emptyListString?: string;-}+};export default function InheritedAttributesTab({ note, componentId, emptyListString }: InheritedAttributesTabArgs) {const [ inheritedAttributes, setInheritedAttributes ] = useState<FAttribute[]>();@@ -23,10 +24,11 @@ export default function InheritedAttributesTab({ note, componentId, emptyListStrattrs.sort((a, b) => {if (a.noteId === b.noteId) {return a.position - b.position;- } else {- // inherited attributes should stay grouped: https://github.com/zadam/trilium/issues/3761- return a.noteId < b.noteId ? -1 : 1;}++ // inherited attributes should stay grouped: https://github.com/zadam/trilium/issues/3761+ return a.noteId < b.noteId ? -1 : 1;+});setInheritedAttributes(attrs);@@ -45,6 +47,7 @@ export default function InheritedAttributesTab({ note, componentId, emptyListStr{inheritedAttributes?.length ? (joinElements(inheritedAttributes.map(attribute => (<InheritedAttribute+ key={attribute.attributeId}attribute={attribute}onClick={(e) => {setTimeout(@@ -73,13 +76,13 @@ export default function InheritedAttributesTab({ note, componentId, emptyListStr{attributeDetailWidgetEl}</div>- )+ );}function InheritedAttribute({ attribute, onClick }: { attribute: FAttribute, onClick: (e: MouseEvent) => void }) {const [ html, setHtml ] = useState<JQuery<HTMLElement> | string>("");useEffect(() => {attribute_renderer.renderAttribute(attribute, false).then(setHtml);- }, []);+ }, [ attribute ]);return (<RawHtml