fix(editor): should auto close dropdown menus on toolbar (#11522)

Closes: [BS-2524](https://linear.app/affine-design/issue/BS-2524/切换-block-后,刷新-toolbar-时,应该自动关闭已经打开的-dropdown)
This commit is contained in:
fundon
2025-04-09 01:29:44 +00:00
parent 984a6763ae
commit c57f41805f
4 changed files with 51 additions and 1 deletions
@@ -1,4 +1,5 @@
import {
type EditorMenuButton,
type EditorToolbar,
renderToolbarSeparator,
} from '@blocksuite/affine-components/toolbar';
@@ -129,6 +130,10 @@ export function autoUpdatePosition(
if (toolbar.dataset.open) {
if (middlewareData.hide.referenceHidden) {
delete toolbar.dataset.open;
// Closes dropdown menus
toolbar
.querySelector<EditorMenuButton>('editor-menu-button[data-open]')
?.hide();
}
} else {
toolbar.dataset.open = 'true';