mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 00:29:59 +01:00
fix(react/ribbon): saving from attribute dialog not working
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
import { useTriliumEvents } from "../react/hooks";
|
||||
import AttributeEditor from "./components/AttributeEditor";
|
||||
import { useMemo, useRef } from "preact/hooks";
|
||||
import { useLegacyImperativeHandlers, useTriliumEvents } from "../react/hooks";
|
||||
import AttributeEditor, { AttributeEditorImperativeHandlers } from "./components/AttributeEditor";
|
||||
import { TabContext } from "./ribbon-interface";
|
||||
|
||||
export default function OwnedAttributesTab({ note, hidden, activate, ntxId, ...restProps }: TabContext) {
|
||||
const api = useRef<AttributeEditorImperativeHandlers>(null);
|
||||
|
||||
useTriliumEvents([ "addNewLabel", "addNewRelation" ], ({ ntxId: eventNtxId }) => {
|
||||
if (ntxId === eventNtxId) {
|
||||
activate();
|
||||
}
|
||||
});
|
||||
|
||||
// Interaction with the attribute editor.
|
||||
useLegacyImperativeHandlers(useMemo(() => ({
|
||||
saveAttributesCommand: () => api.current?.save(),
|
||||
reloadAttributesCommand: () => api.current?.refresh(),
|
||||
updateAttributeListCommand: ({ attributes }) => api.current?.renderOwnedAttributes(attributes)
|
||||
}), [ api ]));
|
||||
|
||||
return (
|
||||
<div className="attribute-list">
|
||||
{ note && (
|
||||
<AttributeEditor ntxId={ntxId} note={note} {...restProps} hidden={hidden} />
|
||||
<AttributeEditor api={api} ntxId={ntxId} note={note} {...restProps} hidden={hidden} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user