fix(react/dialogs): bulk actions not working in search notes

This commit is contained in:
Elian Doran
2025-08-10 14:06:14 +03:00
parent d3519b3059
commit 861374bb87
2 changed files with 21 additions and 9 deletions

View File

@@ -8,14 +8,25 @@ export default abstract class ReactBasicWidget extends BasicWidget {
abstract get component(): JSX.Element;
doRender() {
const renderContainer = new DocumentFragment();
render((
<ParentComponent.Provider value={this}>
{this.component}
</ParentComponent.Provider>
), renderContainer);
this.$widget = $(renderContainer.firstChild as HTMLElement);
doRender() {
this.$widget = renderReactWidget(this, this.component);
}
}
/**
* Renders a React component and returns the corresponding DOM element wrapped in JQuery.
*
* @param parentComponent the parent Trilium component for the component to be able to handle events.
* @param el the JSX element to render.
* @returns the rendered wrapped DOM element.
*/
export function renderReactWidget(parentComponent: Component, el: JSX.Element) {
const renderContainer = new DocumentFragment();
render((
<ParentComponent.Provider value={parentComponent}>
{el}
</ParentComponent.Provider>
), renderContainer);
return $(renderContainer.firstChild as HTMLElement);
}