Skip to content

Commit

Permalink
feat(database): optimize the behavior of the Enter key for the title …
Browse files Browse the repository at this point in the history
…column (toeverything#2962)
  • Loading branch information
zqran authored and Alkaidcc committed Jun 8, 2023
1 parent be4ca1c commit a29815f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export function handleBlockEndEnter(page: Page, model: ExtendedModel) {
const index = parent.children.findIndex(child => child.id === model.id);
let newParent: BaseBlockModel = parent;
let newBlockIndex = index + 1;
const childrenLength = parent.children.length;

if (index === childrenLength - 1 && model.text?.yText.length === 0) {
if (childrenLength !== 1) {
page.deleteBlock(model);
}

if (
index === parent.children.length - 1 &&
model.text?.yText.length === 0
) {
const nextModel = page.getNextSibling(newParent);
if (nextModel && matchFlavours(nextModel, ['affine:paragraph'])) {
asyncFocusRichText(page, nextModel.id, {
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/__internal__/service/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function hardEnter(
if (
isEmptyList &&
parent &&
matchFlavours(parent, ['affine:frame']) &&
matchFlavours(parent, ['affine:frame', 'affine:database']) &&
model.children.length === 0
) {
// TODO use `handleLineStartBackspace` directly is not concise enough,
Expand Down

0 comments on commit a29815f

Please sign in to comment.