Skip to content

Commit

Permalink
feat(database): save the last title being edited (#3101)
Browse files Browse the repository at this point in the history
  • Loading branch information
zqran committed Jun 15, 2023
1 parent 800f210 commit 2b927ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@ export class DatabaseColumnHeader extends WithDisposable(ShadowlessElement) {

private _onEditColumnTitle = (event: MouseEvent, columnId: string) => {
event.stopPropagation();
// If the last clicked column header is being edited, save it first.
if (this._editingColumnId !== '') {
const column = this.columns.find(
column => column.id === this._editingColumnId
);
if (column) {
this._saveColumnTitle('normal', column);
} else {
this._saveColumnTitle('title');
}
}

this.setEditingColumnId(columnId);
};

Expand Down
19 changes: 19 additions & 0 deletions tests/database/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,22 @@ test('should title column support quick changing of column type', async ({
const cell = getFirstColumnCell(page, 'select-selected');
expect(await cell.count()).toBe(1);
});

test('should save the previous header being edited when editing the next column header', async ({
page,
}) => {
await enterPlaygroundRoom(page);
await initEmptyDatabaseState(page);

await initDatabaseColumn(page);
await initDatabaseDynamicRowWithData(page, 'a', true);
await focusDatabaseHeader(page, 0);
const { textElement, renameIcon: titleRenameIcon } =
await getDatabaseHeaderColumn(page, 0);
await titleRenameIcon.click();
await type(page, '123');

const { renameIcon } = await getDatabaseHeaderColumn(page, 1);
await renameIcon.click();
expect(await textElement.innerText()).toBe('123');
});

2 comments on commit 2b927ab

@vercel
Copy link

@vercel vercel bot commented on 2b927ab Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blocksuite – ./packages/playground

blocksuite-five.vercel.app
blocksuite-toeverything.vercel.app
blocksuite-git-master-toeverything.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2b927ab Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.