fix(editor): database block columns popover closes unexpectedly (#11352)

fix: BS-2906
This commit is contained in:
zzj3720
2025-04-01 10:32:23 +00:00
parent 7af5e53838
commit 08327b14d6
6 changed files with 31 additions and 12 deletions
@@ -16,7 +16,7 @@ import {
} from '@blocksuite/icons/lit'; } from '@blocksuite/icons/lit';
import { ShadowlessElement } from '@blocksuite/std'; import { ShadowlessElement } from '@blocksuite/std';
import { nanoid } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store';
import { flip, offset, shift } from '@floating-ui/dom'; import { autoPlacement, offset, shift } from '@floating-ui/dom';
import { computed, type ReadonlySignal, signal } from '@preact/signals-core'; import { computed, type ReadonlySignal, signal } from '@preact/signals-core';
import { cssVarV2 } from '@toeverything/theme/v2'; import { cssVarV2 } from '@toeverything/theme/v2';
import { nothing } from 'lit'; import { nothing } from 'lit';
@@ -588,7 +588,18 @@ export const popTagSelect = (target: PopupTarget, ops: TagSelectOptions) => {
}; };
const remove = createPopup(target, component, { const remove = createPopup(target, component, {
onClose: ops.onComplete, onClose: ops.onComplete,
middleware: [flip(), offset({ mainAxis: -28, crossAxis: 112 }), shift()], middleware: [
autoPlacement({
allowedPlacements: [
'bottom-start',
'bottom-end',
'top-start',
'top-end',
],
}),
offset({ mainAxis: -36 }),
shift(),
],
container: ops.container, container: ops.container,
}); });
return remove; return remove;
@@ -13,7 +13,7 @@ import {
import { ShadowlessElement } from '@blocksuite/std'; import { ShadowlessElement } from '@blocksuite/std';
import { computed, signal } from '@preact/signals-core'; import { computed, signal } from '@preact/signals-core';
import { css } from 'lit'; import { css } from 'lit';
import { property, state } from 'lit/decorators.js'; import { property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js'; import { classMap } from 'lit/directives/class-map.js';
import { html } from 'lit/static-html.js'; import { html } from 'lit/static-html.js';
@@ -249,7 +249,7 @@ export class RecordField extends SignalWatcher(
'field-content': true, 'field-content': true,
empty: !this.isEditing$.value && this.cell$.value.isEmpty$.value, empty: !this.isEditing$.value && this.cell$.value.isEmpty$.value,
'is-editing': this.isEditing$.value, 'is-editing': this.isEditing$.value,
'is-focus': this.isFocus, 'is-focus': this.isFocus$.value,
}); });
return html` return html`
<div> <div>
@@ -271,8 +271,7 @@ export class RecordField extends SignalWatcher(
isEditing$ = signal(false); isEditing$ = signal(false);
@state() isFocus$ = signal(false);
accessor isFocus = false;
@property({ attribute: false }) @property({ attribute: false })
accessor view!: SingleView; accessor view!: SingleView;
@@ -57,7 +57,7 @@ export class DetailSelection {
return; return;
} }
container.isFocus = false; container.isFocus$.value = false;
const cell = container.cell; const cell = container.cell;
if (selection.isEditing) { if (selection.isEditing) {
@@ -80,7 +80,7 @@ export class DetailSelection {
if (!container) { if (!container) {
return; return;
} }
container.isFocus = true; container.isFocus$.value = true;
const cell = container.cell; const cell = container.cell;
if (selection.isEditing) { if (selection.isEditing) {
if (cell?.focusCell()) { if (cell?.focusCell()) {
@@ -59,8 +59,10 @@ export class MultiSelectCell extends BaseCellRenderer<
} }
override beforeExitEditingMode() { override beforeExitEditingMode() {
this.closePopup?.(); requestAnimationFrame(() => {
this.closePopup = undefined; this.closePopup?.();
this.closePopup = undefined;
});
} }
override render() { override render() {
@@ -352,7 +352,10 @@ const FileCellComponent: ForwardRefRenderFunction<
const renderPopoverContent = () => { const renderPopoverContent = () => {
if (fileList.length === 0) { if (fileList.length === 0) {
return ( return (
<div className={styles.uploadPopoverContainer}> <div
data-peek-view-wrapper="true"
className={styles.uploadPopoverContainer}
>
<Button <Button
onClick={() => { onClick={() => {
openFileOrFiles({ multiple: true }) openFileOrFiles({ multiple: true })
@@ -383,7 +386,10 @@ const FileCellComponent: ForwardRefRenderFunction<
); );
} }
return ( return (
<div className={styles.filePopoverContainer}> <div
data-peek-view-wrapper="true"
className={styles.filePopoverContainer}
>
<div className={styles.fileListContainer}> <div className={styles.fileListContainer}>
{fileList.map(file => ( {fileList.map(file => (
<FileListItem <FileListItem
@@ -302,6 +302,7 @@ export const MultiMemberSelect: React.FC<MemberManagerOptions> = props => {
return ( return (
<div <div
data-peek-view-wrapper="true"
className={styles.multiMemberSelectContainer} className={styles.multiMemberSelectContainer}
onClick={() => inputRef.current?.focus()} onClick={() => inputRef.current?.focus()}
> >