mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 08:30:33 +08:00
[@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:
@ -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(
|
||||
|
Reference in New Issue
Block a user