Browse Source

Merge pull request #8192 from nocodb/nc-fix/selected-cell

Nc fix(nc-gui): Use of escape any number of times should not make selected cell go away
pull/8228/head
Ramesh Mane 6 months ago committed by GitHub
parent
commit
cd78fd66be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      packages/nc-gui/components/cell/SingleSelect.vue
  2. 8
      packages/nc-gui/composables/useMultiSelect/index.ts
  3. 5
      tests/playwright/pages/Dashboard/Grid/index.ts
  4. 4
      tests/playwright/pages/Dashboard/WebhookForm/index.ts
  5. 2
      tests/playwright/tests/db/features/undo-redo.spec.ts
  6. 10
      tests/playwright/tests/db/features/webhook.spec.ts

6
packages/nc-gui/components/cell/SingleSelect.vue

@ -254,12 +254,6 @@ const onKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
isOpen.value = false
if (isForm.value) return
setTimeout(() => {
aselect.value?.$el.querySelector('.ant-select-selection-search > input').focus()
}, 100)
}
}

8
packages/nc-gui/composables/useMultiSelect/index.ts

@ -764,14 +764,6 @@ export function useMultiSelect(
}
}
// Handle escape
if (e.key === 'Escape') {
selectedRange.clear()
activeCell.col = null
activeCell.row = null
}
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) {
return true
}

5
tests/playwright/pages/Dashboard/Grid/index.ts

@ -211,6 +211,11 @@ export class GridPage extends BasePage {
return await expect(this.get().locator(`td[data-testid="cell-Title-${index}"]`)).toHaveCount(0);
}
async clickRow(index: number, title = 'Title') {
await this.get().getByTestId(`cell-${title}-${index}`).click();
await this.rootPage.waitForTimeout(300);
}
async deleteRow(index: number, title = 'Title') {
await this.get().getByTestId(`cell-${title}-${index}`).click({
button: 'right',

4
tests/playwright/pages/Dashboard/WebhookForm/index.ts

@ -150,11 +150,11 @@ export class WebhookFormPage extends BasePage {
await this.get().locator(`.ant-tabs-tab-btn:has-text("Headers")`).click();
await this.rootPage.waitForTimeout(500);
await this.get().locator('.nc-input-hook-header-key').click();
await this.get().locator('.nc-input-hook-header-key input').click();
await this.rootPage.waitForTimeout(500);
// kludge, as the dropdown is not visible even after scroll into view
await this.rootPage.locator('.nc-input-hook-header-key').pressSequentially(key);
await this.rootPage.locator('.nc-input-hook-header-key input').pressSequentially(key);
await this.rootPage
.locator('.ant-select-dropdown:visible')
.locator(`.ant-select-item:has-text("${key}")`)

2
tests/playwright/tests/db/features/undo-redo.spec.ts

@ -144,7 +144,9 @@ test.describe('Undo Redo', () => {
await verifyRecords([555, 666]);
// Row.Delete
await grid.clickRow(10, 'Number');
await grid.deleteRow(10, 'Number');
await grid.clickRow(10, 'Number');
await grid.deleteRow(10, 'Number');
await verifyRecords([]);

10
tests/playwright/tests/db/features/webhook.spec.ts

@ -173,6 +173,7 @@ test.describe.serial('Webhook', () => {
// verify that the hook is not triggered (count doesn't change in this case)
await dashboard.grid.editRow({ index: 0, value: 'Delaware' });
await verifyHookTrigger(1, null, request);
await dashboard.grid.clickRow(0);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(1, null, request);
@ -208,6 +209,7 @@ test.describe.serial('Webhook', () => {
request,
buildExpectedResponseData('records.after.update', 'Delaware', 'Poole')
);
await dashboard.grid.clickRow(0);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(3, 'Delaware', request);
@ -241,6 +243,7 @@ test.describe.serial('Webhook', () => {
request,
buildExpectedResponseData('records.after.update', 'Delaware', 'Poole')
);
await dashboard.grid.clickRow(0);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(4, 'Delaware', request, buildExpectedResponseData('records.after.delete', 'Delaware'));
@ -282,6 +285,7 @@ test.describe.serial('Webhook', () => {
await verifyHookTrigger(0, 'Poole', request);
await dashboard.grid.editRow({ index: 0, value: 'Delaware' });
await verifyHookTrigger(0, 'Delaware', request);
await dashboard.grid.clickRow(0);
await dashboard.grid.deleteRow(0);
// for delete, the hook should be triggered (thrice in this case)
@ -313,6 +317,7 @@ test.describe.serial('Webhook', () => {
await verifyHookTrigger(0, '', request);
await dashboard.grid.editRow({ index: 0, value: 'Delaware' });
await verifyHookTrigger(0, '', request);
await dashboard.grid.clickRow(0);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(0, '', request);
});
@ -397,7 +402,9 @@ test.describe.serial('Webhook', () => {
request,
buildExpectedResponseData('records.after.update', 'Poole', 'Delaware')
);
await dashboard.grid.clickRow(1);
await dashboard.grid.deleteRow(1);
await dashboard.rootPage.waitForTimeout(3000);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(3, 'Poole', request, buildExpectedResponseData('records.after.delete', 'Poole'));
@ -439,6 +446,7 @@ test.describe.serial('Webhook', () => {
request,
buildExpectedResponseData('records.after.update', 'Poole', 'Delaware')
);
await dashboard.grid.clickRow(1);
await dashboard.grid.deleteRow(1);
await dashboard.grid.deleteRow(0);
await verifyHookTrigger(8, 'Delaware', request, buildExpectedResponseData('records.after.delete', 'Delaware'));
@ -802,6 +810,8 @@ test.describe.serial('Webhook', () => {
});
}
await dashboard.grid.clickRow(0);
// Select one record and delete
await dashboard.grid.selectRow(0);
await dashboard.grid.deleteSelectedRows();

Loading…
Cancel
Save