diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index d04fbe60b..f0019ac46 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -669,10 +669,17 @@ export function useLegacyWidget(widgetFactory: () => T, { }, [ renderedWidget ]); // Inject the note context - this updates the existing widget without recreating it. + // We check if the context actually changed to avoid double refresh when the event system + // also delivers activeContextChanged to the widget through component tree propagation. useEffect(() => { if (noteContext && widget instanceof NoteContextAwareWidget) { - widget.setNoteContextEvent({ noteContext }); - widget.activeContextChangedEvent({ noteContext }); + // Only trigger refresh if the context actually changed. + // The event system may have already updated the widget, in which case + // widget.noteContext will already equal noteContext. + if (widget.noteContext !== noteContext) { + widget.setNoteContextEvent({ noteContext }); + widget.activeContextChangedEvent({ noteContext }); + } } }, [ noteContext, widget ]);