diff --git a/.changeset/seven-mails-kiss.md b/.changeset/seven-mails-kiss.md new file mode 100644 index 0000000000..f900207e80 --- /dev/null +++ b/.changeset/seven-mails-kiss.md @@ -0,0 +1,5 @@ +--- +'@contentful/f36-menu': patch +--- + +Don’t focus menu if menu has just been removed diff --git a/packages/components/menu/src/Menu.tsx b/packages/components/menu/src/Menu.tsx index 1e0d97e189..8461360d3b 100644 --- a/packages/components/menu/src/Menu.tsx +++ b/packages/components/menu/src/Menu.tsx @@ -103,7 +103,7 @@ export function Menu(props: MenuProps) { }, 0); } else { setTimeout(() => { - menuListRef.current.focus({ preventScroll: false }); + menuListRef.current?.focus({ preventScroll: false }); }, 0); } }