mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
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:
@@ -46,6 +46,12 @@ export class EditorMenuButton extends WithDisposable(LitElement) {
|
||||
composed: true,
|
||||
})
|
||||
);
|
||||
|
||||
if (opened) {
|
||||
this.dataset.open = 'true';
|
||||
} else {
|
||||
delete this.dataset.open;
|
||||
}
|
||||
},
|
||||
mainAxis: 0,
|
||||
offsetHeight: 6 * 4,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
||||
import { TableSelection } from '@blocksuite/affine-block-table';
|
||||
import {
|
||||
darkToolbarStyles,
|
||||
type EditorMenuButton,
|
||||
EditorToolbar,
|
||||
lightToolbarStyles,
|
||||
} from '@blocksuite/affine-components/toolbar';
|
||||
@@ -618,7 +619,7 @@ export class AffineToolbarWidget extends WidgetComponent {
|
||||
})
|
||||
);
|
||||
|
||||
// Update layout when placement changing to `inner`
|
||||
// Updates layout when placement changing to `inner`
|
||||
disposables.add(
|
||||
effect(() => {
|
||||
toolbar.dataset.placement = placement$.value;
|
||||
@@ -632,6 +633,10 @@ export class AffineToolbarWidget extends WidgetComponent {
|
||||
// Hides toolbar
|
||||
if (Flag.None === value || flags.check(Flag.Hiding, value)) {
|
||||
if (toolbar.dataset.open) delete toolbar.dataset.open;
|
||||
// Closes dropdown menus
|
||||
toolbar
|
||||
.querySelector<EditorMenuButton>('editor-menu-button[data-open]')
|
||||
?.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user