Browse Source

fix: Fixed issue with single and multi select click to open in grid

pull/7280/head
Muhammed Mustafa 11 months ago
parent
commit
1261dec6d0
  1. 16
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 15
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 7
      tests/playwright/tests/db/columns/columnSingleSelect.spec.ts

16
packages/nc-gui/components/cell/MultiSelect.vue

@ -1,12 +1,10 @@
<script lang="ts" setup>
import { onUnmounted } from '@vue/runtime-core'
import { message } from 'ant-design-vue'
import tinycolor from 'tinycolor2'
import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType, SelectOptionsType } from 'nocodb-sdk'
import {
ActiveCellInj,
CellClickHookInj,
ColumnInj,
EditColumnInj,
EditModeInj,
@ -299,26 +297,12 @@ const onTagClick = (e: Event, onClose: Function) => {
}
}
const cellClickHook = inject(CellClickHookInj, null)
const toggleMenu = () => {
if (cellClickHook) return
if (isFocusing.value) return
isOpen.value = editAllowed.value && !isOpen.value
}
const cellClickHookHandler = () => {
isOpen.value = editAllowed.value && !isOpen.value
}
onMounted(() => {
cellClickHook?.on(cellClickHookHandler)
})
onUnmounted(() => {
cellClickHook?.on(cellClickHookHandler)
})
const handleClose = (e: MouseEvent) => {
// close dropdown if clicked outside of dropdown
if (

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

@ -1,12 +1,10 @@
<script lang="ts" setup>
import { onUnmounted } from '@vue/runtime-core'
import { message } from 'ant-design-vue'
import tinycolor from 'tinycolor2'
import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType } from 'nocodb-sdk'
import {
ActiveCellInj,
CellClickHookInj,
ColumnInj,
EditColumnInj,
EditModeInj,
@ -232,8 +230,6 @@ const onSelect = () => {
isEditable.value = false
}
const cellClickHook = inject(CellClickHookInj, null)
const toggleMenu = (e: Event) => {
// todo: refactor
// check clicked element is clear icon
@ -244,23 +240,12 @@ const toggleMenu = (e: Event) => {
vModel.value = ''
return e.stopPropagation()
}
if (cellClickHook) return
if (isFocusing.value) return
isOpen.value = editAllowed.value && !isOpen.value
}
const cellClickHookHandler = () => {
isOpen.value = editAllowed.value && !isOpen.value
}
onMounted(() => {
cellClickHook?.on(cellClickHookHandler)
})
onUnmounted(() => {
cellClickHook?.on(cellClickHookHandler)
})
const handleClose = (e: MouseEvent) => {
if (isOpen.value && aselect.value && !aselect.value.$el.contains(e.target)) {
isOpen.value = false

7
tests/playwright/tests/db/columns/columnSingleSelect.spec.ts

@ -39,7 +39,12 @@ test.describe('Single select', () => {
await grid.column.selectOption.addOption({ index: 2, option: 'Option 3', columnTitle: 'SingleSelect' });
await grid.cell.selectOption.select({ index: 0, columnHeader: 'SingleSelect', option: 'Option 3' });
await grid.cell.selectOption.select({
index: 0,
columnHeader: 'SingleSelect',
option: 'Option 3',
ignoreDblClick: true,
});
await grid.cell.selectOption.verify({ index: 0, columnHeader: 'SingleSelect', option: 'Option 3' });
await grid.column.selectOption.editOption({ index: 2, columnTitle: 'SingleSelect', newOption: 'New Option 3' });

Loading…
Cancel
Save