diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx index 5d2d917ca..452fa1b4a 100644 --- a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx +++ b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx @@ -5,6 +5,7 @@ import { Header, Menu, Scroll, config } from 'folds'; import * as css from './AutocompleteMenu.css'; import { preventScrollWithArrowKey, stopPropagation } from '../../../utils/keyboard'; +import { useAlive } from '../../../hooks/useAlive'; type AutocompleteMenuProps = { requestClose: () => void; @@ -12,13 +13,22 @@ type AutocompleteMenuProps = { children: ReactNode; }; export function AutocompleteMenu({ headerContent, requestClose, children }: AutocompleteMenuProps) { + const alive = useAlive(); + + const handleDeactivate = () => { + if (alive()) { + // The component is unmounted so we will not call for `requestClose` + requestClose(); + } + }; + return (