[@lexical/react] Bug Fix: anchor element not cleanup when component unmount (#7264)

Co-authored-by: Bob Ippolito <bob@redivi.com>
This commit is contained in:
Y2
2025-03-01 04:37:34 +08:00
committed by GitHub
parent 99e64bc4fd
commit 21734b6b8c

View File

@ -572,18 +572,18 @@ export function useMenuAnchorRef(
const rootElement = editor.getRootElement();
if (resolution !== null) {
positionMenu();
return () => {
if (rootElement !== null) {
rootElement.removeAttribute('aria-controls');
}
const containerDiv = anchorElementRef.current;
if (containerDiv !== null && containerDiv.isConnected) {
containerDiv.remove();
containerDiv.removeAttribute('id');
}
};
}
return () => {
if (rootElement !== null) {
rootElement.removeAttribute('aria-controls');
}
const containerDiv = anchorElementRef.current;
if (containerDiv !== null && containerDiv.isConnected) {
containerDiv.remove();
containerDiv.removeAttribute('id');
}
};
}, [editor, positionMenu, resolution]);
const onVisibilityChange = useCallback(