diff --git a/packages/nc-gui/components/cell/Checkbox.vue b/packages/nc-gui/components/cell/Checkbox.vue index 1de2de9d79..f482d24511 100644 --- a/packages/nc-gui/components/cell/Checkbox.vue +++ b/packages/nc-gui/components/cell/Checkbox.vue @@ -89,7 +89,7 @@ useSelectedCellKeyupListener(active, (e) => { diff --git a/packages/nc-gui/components/smartsheet/Cell.vue b/packages/nc-gui/components/smartsheet/Cell.vue index be23b134d5..f39454f7f4 100644 --- a/packages/nc-gui/components/smartsheet/Cell.vue +++ b/packages/nc-gui/components/smartsheet/Cell.vue @@ -139,6 +139,15 @@ const isNumericField = computed(() => { isDuration(column.value) ) }) + +// disable contexxtmenu event propagation when cell is in +// editable state and typable (e.g. text area) +// this is to prevent the custom grid view context menu from opening +const onContextmenu = (e: MouseEvent) => { + if (props.editEnabled && isTypableInputColumn(column.value)) { + e.stopPropagation() + } +} @@ -151,6 +160,7 @@ const isNumericField = computed(() => { ]" @keydown.enter.exact="syncAndNavigate(NavigateDir.NEXT, $event)" @keydown.shift.enter.exact="syncAndNavigate(NavigateDir.PREV, $event)" + @contextmenu="onContextmenu" > diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index f453f8f8db..b78e093089 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -101,17 +101,6 @@ const onConfirmDeleteRowClick = async () => { - - - - {{ $t('general.reload') }} - - - @@ -137,32 +126,6 @@ const onConfirmDeleteRowClick = async () => { /> - - - - {{ $t('activity.duplicateRow') }} - - - - - - - - {{ $t('activity.deleteRow') }} - - - - @@ -192,17 +155,39 @@ const onConfirmDeleteRowClick = async () => { - - - - {{ $t('general.close') }} + + + + + + + + {{ $t('general.reload') }} + + + + + + {{ $t('activity.duplicateRow') }} + + + + + + {{ $t('activity.deleteRow') }} + + + + + + {{ $t('general.close') }} + + + - - - + Are you sure you want to delete this row? diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index f72807f0cf..35cb7b852f 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -141,8 +141,22 @@ const onDuplicateRow = () => { } const onNext = async () => { - await save() - emits('next') + if (changedColumns.value.size > 0) { + await Modal.confirm({ + title: 'Do you want to save the changes?', + okText: 'Save', + cancelText: 'Discard', + onOk: async () => { + await save() + emits('next') + }, + onCancel: () => { + emits('next') + }, + }) + } else { + emits('next') + } } const reloadParentRowHook = inject(ReloadRowDataHookInj, createEventHook()) @@ -196,7 +210,7 @@ useActiveKeyupListener( emits('prev') } else if (e.key === 'ArrowRight') { e.stopPropagation() - emits('next') + onNext() } // on alt + s save record else if (e.code === 'KeyS') { @@ -319,7 +333,8 @@ export default { :ref="i ? null : (el) => (cellWrapperEl = el)" class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2 relative" > - + - + @@ -230,7 +235,7 @@ defineExpose({ - + +import { nextTick } from '@vue/runtime-core' import type { ColumnType } from 'nocodb-sdk' import { ActiveViewInj, @@ -22,7 +23,17 @@ const reloadDataHook = inject(ReloadViewDataHookInj) const { eventBus } = useSmartsheetStoreOrThrow() -const { sorts, saveOrUpdate, loadSorts, addSort, deleteSort } = useViewSorts(view, () => reloadDataHook?.trigger()) +const { sorts, saveOrUpdate, loadSorts, addSort: _addSort, deleteSort } = useViewSorts(view, () => reloadDataHook?.trigger()) + +const removeIcon = ref() + +const addSort = () => { + _addSort() + nextTick(() => { + console.log(removeIcon.value) + removeIcon.value?.[removeIcon.value?.length - 1]?.$el?.scrollIntoView() + }) +} eventBus.on((event) => { if (event === SmartsheetStoreEvents.SORT_RELOAD) { @@ -75,12 +86,18 @@ useMenuCloseOnEsc(open) - + - + ([]) const comment = ref('') - const commentsDrawer = ref(false) + const commentsDrawer = ref(true) const saveRowAndStay = ref(0) diff --git a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts index a53971469c..ce6b0f8660 100644 --- a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -24,16 +24,25 @@ export class ExpandedFormPage extends BasePage { return this.dashboard.get().locator(`.nc-drawer-expanded-form`); } - async clickDuplicateRow() { - await this.duplicateRowButton.click(); + async click3DotsMenu(menuItem: string) { + await this.get().locator('.nc-icon-transition.ant-dropdown-trigger').last().click(); + + // add delay; wait for the menu to appear + await this.rootPage.waitForTimeout(500); + const popUpMenu = await this.rootPage.locator('.ant-dropdown'); + await popUpMenu.locator(`.ant-dropdown-menu-item:has-text("${menuItem}")`).click(); + } + + async clickDuplicateRow() { + await this.click3DotsMenu('Duplicate Row'); // wait for loader to disappear // await this.dashboard.waitForLoaderToDisappear(); await this.rootPage.waitForTimeout(2000); } async clickDeleteRow() { - await this.deleteRowButton.click(); + await this.click3DotsMenu('Delete Row'); await this.rootPage.locator('.ant-btn-primary:has-text("OK")').click(); } @@ -142,7 +151,7 @@ export class ExpandedFormPage extends BasePage { } async close() { - await this.get().locator('.nc-close-form').last().click(); + await this.click3DotsMenu('Close'); } async openChildCard(param: { column: string; title: string }) { diff --git a/tests/playwright/pages/Dashboard/Grid/index.ts b/tests/playwright/pages/Dashboard/Grid/index.ts index 28b497fd94..ed3d420993 100644 --- a/tests/playwright/pages/Dashboard/Grid/index.ts +++ b/tests/playwright/pages/Dashboard/Grid/index.ts @@ -283,6 +283,9 @@ export class GridPage extends BasePage { }); await expect(await cell.locator('input')).toBeVisible(); + // press escape to exit edit mode + await cell.press('Escape'); + // right click menu await this.get().locator(`td[data-testid="cell-${columnHeader}-0"]`).click({ button: 'right', diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 5d5da5f46e..23f9b0d0b1 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -289,8 +289,11 @@ export class CellPageObject extends BasePage { // editable cell await cell.dblclick(); await expect(await cell.locator(`input`)).toHaveCount(param.role === 'creator' || param.role === 'editor' ? 1 : 0); - // right click context menu - await cell.click({ button: 'right' }); + + // press escape to close the input + await cell.press('Escape'); + + await cell.click({ button: 'right', clickCount: 1 }); await expect(await this.rootPage.locator(`.nc-dropdown-grid-context-menu:visible`)).toHaveCount( param.role === 'creator' || param.role === 'editor' ? 1 : 0 );
Are you sure you want to delete this row?