From 38dde7f5b7b81d0bcac728bd58053bf2bba02cb0 Mon Sep 17 00:00:00 2001 From: akumatus <12724894+akumatus@users.noreply.github.com> Date: Fri, 7 Jun 2024 02:48:36 +0000 Subject: [PATCH] feat: add autofill and onClose params in notification service api (#7162) This PR add autofill and onClose params in notification service api for better user experiences. [Related PR in blocksuite](https://github.com/toeverything/blocksuite/pull/7230) --- .../specs/custom/spec-patchers.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx index a9c36ad7d..482c98f3d 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx @@ -169,14 +169,19 @@ export function patchNotificationService( confirmText, placeholder, cancelText, + autofill, abort, }) => { return new Promise(resolve => { - let value = ''; + let value = autofill || ''; const description = (
{toReactNode(message)} - (value = e)} /> + (value = e)} + />
); openConfirmModal({ @@ -189,7 +194,6 @@ export function patchNotificationService( cancelButtonOptions: { children: cancelText ?? 'Cancel', }, - onConfirm: () => { resolve(value); }, @@ -229,9 +233,12 @@ export function patchNotificationService( onClick: notification.action.onClick, } : undefined, + onDismiss: notification.onClose, }, { duration: notification.duration || 0, + onDismiss: notification.onClose, + onAutoClose: notification.onClose, } );