Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(database): move cursor in kanban card title by arrow keys #8893

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ export class KanbanHotkeysController implements ReactiveController {
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowLeft: context => {
ArrowLeft: () => {
if (!this.hasSelection) return false;

this.host.selectionController.focusNext('left');
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowRight: context => {
ArrowRight: () => {
if (!this.hasSelection) return false;

this.host.selectionController.focusNext('right');
context.get('keyboardState').raw.preventDefault();
return true;
},
Backspace: () => {
Expand Down
16 changes: 16 additions & 0 deletions tests/database/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,22 @@ export async function focusKanbanCardHeader(page: Page, index = 0) {
await cardHeader.click();
}

export async function clickKanbanCardHeader(page: Page, index = 0) {
const cardHeader = page.locator('data-view-header-area-text').nth(index);
await cardHeader.click();
await cardHeader.click();
}

export async function assertKanbanCardHeaderText(
page: Page,
text: string,
index = 0
) {
const cardHeader = page.locator('data-view-header-area-text').nth(index);

await expect(cardHeader).toHaveText(text);
}

export async function assertKanbanCellSelected(
page: Page,
{
Expand Down
26 changes: 26 additions & 0 deletions tests/database/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import { test } from '../utils/playwright.js';
import {
assertCellsSelection,
assertDatabaseTitleColumnText,
assertKanbanCardHeaderText,
assertKanbanCardSelected,
assertKanbanCellSelected,
assertRowsSelection,
clickKanbanCardHeader,
focusKanbanCardHeader,
getDatabaseBodyCell,
getKanbanCard,
Expand Down Expand Up @@ -538,4 +540,28 @@ test.describe('kanban view selection', () => {
cardIndex: 0,
});
});

test("should support move cursor in card's title by arrow key(left&right)", async ({
page,
}) => {
await enterPlaygroundRoom(page);
await initKanbanViewState(page, {
rows: ['row1'],
columns: [
{
type: 'rich-text',
value: ['text'],
},
],
});

await clickKanbanCardHeader(page);
await type(page, 'abc');
await pressArrowLeft(page, 2);
await pressArrowRight(page);
await pressBackspace(page);
await pressEscape(page);

await assertKanbanCardHeaderText(page, 'row1ac');
});
});
Loading