From 395dbfae04d17c2cd968d5b6daefadd09b05a43f Mon Sep 17 00:00:00 2001 From: Anatoly Rubinshteyn Date: Mon, 27 Jul 2026 23:14:51 +0300 Subject: [PATCH] fix(editor): guard tippy instance in suggestion handlers (#543) The popup variable stays undefined when onStart bails out early because props.clientRect is missing, so popup[0] throws instead of no-oping. Use optional chaining on the array itself. --- apps/web/src/components/Editor.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/Editor.tsx b/apps/web/src/components/Editor.tsx index ce3dff20..b5aa782b 100644 --- a/apps/web/src/components/Editor.tsx +++ b/apps/web/src/components/Editor.tsx @@ -180,13 +180,13 @@ const RenderSuggestions = () => { if (!props.clientRect) return; - popup[0]?.setProps({ + popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect, }); }, onKeyDown(props: SuggestionKeyDownProps): boolean { if (props.event.key === "Escape") { - popup[0]?.hide(); + popup?.[0]?.hide(); return true; } @@ -199,7 +199,7 @@ const RenderSuggestions = () => { ); }, onExit() { - popup[0]?.destroy(); + popup?.[0]?.destroy(); reactRenderer.destroy(); }, }; @@ -308,11 +308,11 @@ const renderMentionSuggestions = () => { onUpdate(props: any) { reactRenderer.updateProps(props); if (!props.clientRect) return; - popup[0]?.setProps({ getReferenceClientRect: props.clientRect }); + popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect }); }, onKeyDown(props: SuggestionKeyDownProps) { if (props.event.key === "Escape") { - popup[0]?.hide(); + popup?.[0]?.hide(); return true; } return ( @@ -324,7 +324,7 @@ const renderMentionSuggestions = () => { ); }, onExit() { - popup[0]?.destroy(); + popup?.[0]?.destroy(); reactRenderer.destroy(); }, };