fix(core): values in edit not saved when closing info modal (#7465)
Before the modification, when the modal is closed, if a value is being edited, the input's on blur event cannot be triggered to automatically save. https://github.com/toeverything/AFFiNE/assets/102217452/60235cec-0022-4c4d-b213-28f2331a0c5b
This commit is contained in:
@@ -1,13 +1,46 @@
|
|||||||
import { cssVar } from '@toeverything/theme';
|
import { cssVar } from '@toeverything/theme';
|
||||||
import { style } from '@vanilla-extract/css';
|
import { createVar, keyframes, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const container = style({
|
export const animationTimeout = createVar();
|
||||||
|
|
||||||
|
const contentShow = keyframes({
|
||||||
|
from: {
|
||||||
|
opacity: 0,
|
||||||
|
},
|
||||||
|
to: {
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const contentHide = keyframes({
|
||||||
|
to: {
|
||||||
|
opacity: 0,
|
||||||
|
},
|
||||||
|
from: {
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const overlay = style({
|
||||||
|
selectors: {
|
||||||
|
'&.entered, &.entering': {
|
||||||
|
animation: `${contentShow} ${animationTimeout} forwards`,
|
||||||
|
},
|
||||||
|
'&.exited, &.exiting': {
|
||||||
|
animation: `${contentHide} ${animationTimeout} forwards`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const container = style([
|
||||||
|
overlay,
|
||||||
|
{
|
||||||
maxWidth: 480,
|
maxWidth: 480,
|
||||||
minWidth: 360,
|
minWidth: 360,
|
||||||
padding: '20px 0',
|
padding: '20px 0',
|
||||||
alignSelf: 'start',
|
alignSelf: 'start',
|
||||||
marginTop: '120px',
|
marginTop: '120px',
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
export const titleContainer = style({
|
export const titleContainer = style({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -37,3 +70,9 @@ export const scrollBar = style({
|
|||||||
width: 6,
|
width: 6,
|
||||||
transform: 'translateX(-4px)',
|
transform: 'translateX(-4px)',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const hiddenInput = style({
|
||||||
|
width: '0',
|
||||||
|
height: '0',
|
||||||
|
position: 'absolute',
|
||||||
|
});
|
||||||
|
|||||||
@@ -12,7 +12,17 @@ import {
|
|||||||
useService,
|
useService,
|
||||||
type Workspace,
|
type Workspace,
|
||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import { Suspense, useCallback, useContext, useMemo, useRef } from 'react';
|
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import {
|
||||||
|
Suspense,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
} from 'react';
|
||||||
|
import { useTransition } from 'react-transition-state';
|
||||||
|
|
||||||
import { BlocksuiteHeaderTitle } from '../../../blocksuite/block-suite-header/title';
|
import { BlocksuiteHeaderTitle } from '../../../blocksuite/block-suite-header/title';
|
||||||
import { managerContext } from '../common';
|
import { managerContext } from '../common';
|
||||||
@@ -27,6 +37,8 @@ import * as styles from './info-modal.css';
|
|||||||
import { TagsRow } from './tags-row';
|
import { TagsRow } from './tags-row';
|
||||||
import { TimeRow } from './time-row';
|
import { TimeRow } from './time-row';
|
||||||
|
|
||||||
|
const animationTimeout = 120;
|
||||||
|
|
||||||
export const InfoModal = ({
|
export const InfoModal = ({
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
@@ -39,7 +51,17 @@ export const InfoModal = ({
|
|||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
}) => {
|
}) => {
|
||||||
const titleInputHandleRef = useRef<InlineEditHandle>(null);
|
const titleInputHandleRef = useRef<InlineEditHandle>(null);
|
||||||
|
|
||||||
|
const [{ status }, toggle] = useTransition({
|
||||||
|
timeout: animationTimeout,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
toggle(open);
|
||||||
|
}, [open, toggle]);
|
||||||
|
|
||||||
const manager = usePagePropertiesManager(page);
|
const manager = usePagePropertiesManager(page);
|
||||||
|
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
}, [onOpenChange]);
|
}, [onOpenChange]);
|
||||||
@@ -58,11 +80,20 @@ export const InfoModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
contentOptions={{
|
overlayOptions={{
|
||||||
className: styles.container,
|
className: clsx(styles.overlay, status),
|
||||||
'aria-describedby': undefined,
|
style: assignInlineVars({
|
||||||
|
[styles.animationTimeout]: `${animationTimeout}ms`,
|
||||||
|
}),
|
||||||
}}
|
}}
|
||||||
open={open}
|
contentOptions={{
|
||||||
|
className: clsx(styles.container, status),
|
||||||
|
'aria-describedby': undefined,
|
||||||
|
style: assignInlineVars({
|
||||||
|
[styles.animationTimeout]: `${animationTimeout}ms`,
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
open={status !== 'exited'}
|
||||||
onOpenChange={onOpenChange}
|
onOpenChange={onOpenChange}
|
||||||
withoutCloseButton
|
withoutCloseButton
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user