Browse Source

Merge pull request #6865 from nocodb/nc-fix/lookup-overflow-fix

Nc fix/lookup overflow fix
pull/6873/head
Raju Udava 1 year ago committed by GitHub
parent
commit
5e540c1e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 78
      packages/nc-gui/components/virtual-cell/Lookup.vue

78
packages/nc-gui/components/virtual-cell/Lookup.vue

@ -25,6 +25,14 @@ const meta = inject(MetaInj, ref())
const cellValue = inject(CellValueInj, ref()) const cellValue = inject(CellValueInj, ref())
// Change the row height of the child cell under lookup
// Other wise things like text will can take multi line tag
const providedHeightRef = ref(1) as any
const rowHeight = inject(RowHeightInj, ref(1) as any)
provide(RowHeightInj, providedHeightRef)
const relationColumn = computed( const relationColumn = computed(
() => () =>
meta.value?.columns?.find((c: ColumnType) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id) as meta.value?.columns?.find((c: ColumnType) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id) as
@ -56,6 +64,14 @@ const lookupColumn = computed(
| undefined, | undefined,
) )
watch([lookupColumn, rowHeight], () => {
if (lookupColumn.value && !isAttachment(lookupColumn.value)) {
providedHeightRef.value = 1
} else {
providedHeightRef.value = rowHeight.value
}
})
const arrValue = computed(() => { const arrValue = computed(() => {
if (!cellValue.value) return [] if (!cellValue.value) return []
@ -64,7 +80,8 @@ const arrValue = computed(() => {
if (lookupColumn.value?.uidt === UITypes.Attachment && relationColumn.value?.colOptions?.type === RelationTypes.BELONGS_TO) if (lookupColumn.value?.uidt === UITypes.Attachment && relationColumn.value?.colOptions?.type === RelationTypes.BELONGS_TO)
return [cellValue.value] return [cellValue.value]
if (Array.isArray(cellValue.value)) return cellValue.value // TODO: We are filtering null as cell value can be null. Find the root cause and fix it
if (Array.isArray(cellValue.value)) return cellValue.value.filter((v) => v !== null)
return [cellValue.value] return [cellValue.value]
}) })
@ -80,8 +97,17 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activ
</script> </script>
<template> <template>
<div class="h-full" @dblclick="activateShowEditNonEditableFieldWarning"> <div
<div class="h-full flex gap-1 overflow-x-auto p-1"> class="h-full w-full"
:style="{ height: rowHeight && rowHeight !== 1 ? `${rowHeight * 2}rem` : `2.85rem` }"
@dblclick="activateShowEditNonEditableFieldWarning"
>
<div
class="h-full w-full flex gap-1 p-1"
:class="{
'!overflow-x-auto nc-cell-lookup-scroll nc-scrollbar-x-md !overflow-y-hidden': rowHeight === 1,
}"
>
<template v-if="lookupColumn"> <template v-if="lookupColumn">
<!-- Render virtual cell --> <!-- Render virtual cell -->
<div v-if="isVirtualCol(lookupColumn)"> <div v-if="isVirtualCol(lookupColumn)">
@ -114,17 +140,31 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activ
</div> </div>
<!-- For attachment cell avoid adding chip style --> <!-- For attachment cell avoid adding chip style -->
<template v-else> <template v-else>
<div class="flex flex-col"> <div
<div class="flex gap-1.5"> class="max-h-full max-w-full w-full nc-cell-lookup-scroll"
:class="{
'nc-scrollbar-md ': rowHeight !== 1 && !isAttachment(lookupColumn),
}"
>
<div
class="flex gap-1.5 w-full"
:class="{
'flex-wrap': rowHeight !== 1 && !isAttachment(lookupColumn),
'!overflow-x-auto nc-cell-lookup-scroll nc-scrollbar-x-md !overflow-y-hidden':
rowHeight === 1 || isAttachment(lookupColumn),
}"
>
<div <div
v-for="(v, i) of arrValue" v-for="(v, i) of arrValue"
:key="i" :key="i"
class="min-w-max"
:class="{ :class="{
'bg-gray-100 px-1 rounded-full flex-1': !isAttachment(lookupColumn), 'bg-gray-100 px-1 rounded-full min-h-7.5': !isAttachment(lookupColumn),
'border-gray-200 rounded border-1': ![UITypes.Attachment, UITypes.MultiSelect, UITypes.SingleSelect].includes( 'border-gray-200 rounded border-1 pt-0.75': ![
lookupColumn.uidt, UITypes.Attachment,
), UITypes.MultiSelect,
UITypes.SingleSelect,
].includes(lookupColumn.uidt),
'min-h-0 min-w-0': isAttachment(lookupColumn),
}" }"
> >
<LazySmartsheetCell <LazySmartsheetCell
@ -133,6 +173,11 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activ
:edit-enabled="false" :edit-enabled="false"
:virtual="true" :virtual="true"
:read-only="true" :read-only="true"
class=""
:class="{
'min-h-0 min-w-0': isAttachment(lookupColumn),
'!max-w-40 !min-w-20 !w-auto px-2': !isAttachment(lookupColumn),
}"
/> />
</div> </div>
</div> </div>
@ -149,3 +194,16 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activ
</div> </div>
</div> </div>
</template> </template>
<style lang="scss">
.nc-cell-lookup-scroll {
&::-webkit-scrollbar-thumb {
@apply bg-transparent;
}
}
.nc-cell-lookup-scroll:hover {
&::-webkit-scrollbar-thumb {
@apply bg-gray-200;
}
}
</style>

Loading…
Cancel
Save