There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: use the esc shortcut to exit in create collection dialog (#6138)
Fangdun Tsaieec24db1a146
diff --git a/packages/frontend/core/src/components/page-list/view/create-collection.tsx b/packages/frontend/core/src/components/page-list/view/create-collection.tsxindex 34083054d0..c075868aef 100644--- a/packages/frontend/core/src/components/page-list/view/create-collection.tsx+++ b/packages/frontend/core/src/components/page-list/view/create-collection.tsx@@ -1,5 +1,6 @@import { Button, Input, Modal } from '@affine/component';import { useAFFiNEI18N } from '@affine/i18n/hooks';+import { type KeyboardEvent } from 'react';import { useCallback, useMemo, useState } from 'react';import * as styles from './create-collection.css';@@ -73,6 +74,19 @@ export const CreateCollection = ({}onConfirm(value);}, [onConfirm, value, isNameEmpty]);+ const onKeyDown = useCallback(+ (e: KeyboardEvent<HTMLInputElement>) => {+ if (e.key === 'Escape') {+ if (isNameEmpty) {+ return;+ } else {+ e.currentTarget.blur();+ }+ }+ e.stopPropagation();+ },+ [isNameEmpty]+ );return (<div><div className={styles.content}>@@ -82,13 +96,11 @@ export const CreateCollection = ({<InputautoFocusvalue={value}- onKeyDown={e => {- e.stopPropagation();- }}data-testid="input-collection-title"placeholder={t['com.affine.editCollectionName.name.placeholder']()}onChange={useCallback((value: string) => onChange(value), [onChange])}onEnter={save}+ onKeyDown={onKeyDown}></Input>{showTips ? (<div className={styles.createTips}>