Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): increase table header height in mobile view

Ramesh Mane98da02b0a483
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
index 33fd723254..2cf7955050 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
@@ -21,7 +21,6 @@ import type { TableMetaLoader } from '../loaders/TableMetaLoader'
import {
ADD_NEW_COLUMN_WIDTH,
AGGREGATION_HEIGHT,
- COLUMN_HEADER_HEIGHT_IN_PX,
GROUP_EXPANDED_BOTTOM_PADDING,
GROUP_HEADER_HEIGHT,
GROUP_PADDING,
@@ -51,6 +50,7 @@ export function useCanvasRender({
scrollTop,
rowSlice,
rowHeight,
+ headerRowHeight,
activeCell,
dragOver,
hoverRow,
@@ -102,6 +102,7 @@ export function useCanvasRender({
width: Ref<number>
height: Ref<number>
rowHeight: Ref<number>
+ headerRowHeight: Ref<number>
columns: ComputedRef<CanvasGridColumn[]>
colSlice: Ref<{ start: number; end: number }>
rowSlice: Ref<{ start: number; end: number }>
@@ -235,7 +236,7 @@ export function useCanvasRender({
// Header background
ctx.fillStyle = '#f4f4f5'
- ctx.fillRect(0, 0, columnsWidth, 32)
+ ctx.fillRect(0, 0, columnsWidth, headerRowHeight.value)
// Header borders
ctx.strokeStyle = '#e7e7e9'
@@ -243,8 +244,8 @@ export function useCanvasRender({
// Bottom border
ctx.beginPath()
- ctx.moveTo(0, 32)
- ctx.lineTo(columnsWidth, 32)
+ ctx.moveTo(0, headerRowHeight.value)
+ ctx.lineTo(columnsWidth, headerRowHeight.value)
ctx.stroke()
const { start: startColIndex, end: endColIndex } = colSlice.value
@@ -282,7 +283,7 @@ export function useCanvasRender({
xOffset += width
ctx.beginPath()
ctx.moveTo(xOffset - scrollLeft.value, 0)
- ctx.lineTo(xOffset - scrollLeft.value, 32)
+ ctx.lineTo(xOffset - scrollLeft.value, headerRowHeight.value)
ctx.stroke()
continue
}
@@ -292,7 +293,7 @@ export function useCanvasRender({
if (columnState) {
renderTag(ctx, {
- height: 31.5,
+ height: headerRowHeight.value - 0.5,
width,
x: xOffset - scrollLeft.value,
y: 0,
@@ -300,7 +301,7 @@ export function useCanvasRender({
fillStyle: '#ffffff88',
})
renderTag(ctx, {
- height: 32,
+ height: headerRowHeight.value,
width,
x: xOffset - scrollLeft.value,
y: 0,
@@ -334,7 +335,7 @@ export function useCanvasRender({
size: 13,
color: iconConfig?.hex ?? '#6a7184',
x: xOffset + 8 - scrollLeft.value,
- y: 8,
+ y: headerRowHeight.value / 2 - 7,
})
}
@@ -342,11 +343,11 @@ export function useCanvasRender({
const availableTextWidth = width - (26 + iconSpace + (isRequired ? 4 : 0))
const truncatedText = truncateText(ctx, column.title!, availableTextWidth)
- ctx.fillText(truncatedText, xOffset + 26 - scrollLeft.value, 16)
+ ctx.fillText(truncatedText, xOffset + 26 - scrollLeft.value, headerRowHeight.value / 2)
if (isRequired) {
ctx.save()
ctx.fillStyle = '#EF4444'
- ctx.fillText('*', xOffset + 28 - scrollLeft.value + ctx.measureText(truncatedText).width, 16)
+ ctx.fillText('*', xOffset + 28 - scrollLeft.value + ctx.measureText(truncatedText).width, headerRowHeight.value / 2)
ctx.restore()
}
@@ -359,7 +360,7 @@ export function useCanvasRender({
size: 14,
color: '#6a7184',
x: rightOffset - scrollLeft.value,
- y: 9,
+ y: headerRowHeight.value / 2 - 7,
})
} else if (meta.value?.synced && colObj?.readonly) {
rightOffset -= 16
@@ -368,7 +369,7 @@ export function useCanvasRender({
size: 14,
color: '#6a7184',
x: rightOffset - scrollLeft.value,
- y: 9,
+ y: headerRowHeight.value / 2 - 7,
})
}
@@ -379,7 +380,7 @@ export function useCanvasRender({
size: 14,
color: '#FF928C',
x: rightOffset - scrollLeft.value,
- y: 9,
+ y: headerRowHeight.value / 2 - 7 + 1,
})
}
@@ -390,14 +391,16 @@ export function useCanvasRender({
size: 13,
color: '#6B7280',
x: rightOffset - scrollLeft.value,
- y: 9,
+ y: headerRowHeight.value / 2 - 7,
})
}
xOffset += width
const resizeHandleWidth = 10
const isNearEdge =
- mousePosition && Math.abs(xOffset - scrollLeft.value - mousePosition.x) <= resizeHandleWidth && mousePosition.y <= 32
+ mousePosition &&
+ Math.abs(xOffset - scrollLeft.value - mousePosition.x) <= resizeHandleWidth &&
+ mousePosition.y <= headerRowHeight.value
if (isNearEdge && !isLocked.value) {
colResizeHoveredColIds.value.add(column.id)
@@ -405,7 +408,7 @@ export function useCanvasRender({
ctx.lineWidth = 2
ctx.beginPath()
ctx.moveTo(xOffset - scrollLeft.value, 0)
- ctx.lineTo(xOffset - scrollLeft.value, 32)
+ ctx.lineTo(xOffset - scrollLeft.value, headerRowHeight.value)
ctx.stroke()
// Reset for regular column separator
@@ -415,30 +418,30 @@ export function useCanvasRender({
colResizeHoveredColIds.value.delete(column.id)
ctx.beginPath()
ctx.moveTo(xOffset - scrollLeft.value, 0)
- ctx.lineTo(xOffset - scrollLeft.value, 32)
+ ctx.lineTo(xOffset - scrollLeft.value, headerRowHeight.value)
ctx.stroke()
}
}
if (isAddingColumnAllowed.value && !isMobileMode.value) {
ctx.fillStyle = '#F9F9FA'
- ctx.fillRect(xOffset - scrollLeft.value, 0, plusColumnWidth, 32)
+ ctx.fillRect(xOffset - scrollLeft.value, 0, plusColumnWidth, headerRowHeight.value)
spriteLoader.renderIcon(ctx, {
icon: 'ncPlus',
size: 16,
color: '#6a7184',
x: xOffset + plusColumnWidth / 2 - 8 - scrollLeft.value,
- y: 8,
+ y: headerRowHeight.value / 2 - 8,
})
ctx.beginPath()
ctx.moveTo(xOffset + plusColumnWidth - scrollLeft.value, 0)
- ctx.lineTo(xOffset + plusColumnWidth - scrollLeft.value, 32)
+ ctx.lineTo(xOffset + plusColumnWidth - scrollLeft.value, headerRowHeight.value)
ctx.stroke()
ctx.beginPath()
- ctx.moveTo(xOffset - scrollLeft.value, 32)
- ctx.lineTo(xOffset + plusColumnWidth - scrollLeft.value, 32)
+ ctx.moveTo(xOffset - scrollLeft.value, headerRowHeight.value)
+ ctx.lineTo(xOffset + plusColumnWidth - scrollLeft.value, headerRowHeight.value)
ctx.stroke()
}
@@ -457,7 +460,7 @@ export function useCanvasRender({
ctx.strokeStyle = '#f4f4f5'
if (fillHandler && activeState?.y) {
ctx.beginPath()
- ctx.moveTo(xOffset - scrollLeft.value, 32)
+ ctx.moveTo(xOffset - scrollLeft.value, headerRowHeight.value)
ctx.lineTo(xOffset - scrollLeft.value, activeState.y)
ctx.stroke()
}
@@ -468,9 +471,9 @@ export function useCanvasRender({
ctx.beginPath()
if (selection.value.start.col !== selection.value.end.col) {
- ctx.moveTo(xOffset - scrollLeft.value, activeState ? activeState.y : 32)
+ ctx.moveTo(xOffset - scrollLeft.value, activeState ? activeState.y : headerRowHeight.value)
} else {
- let y = activeState ? activeState.y + activeState.height : 32
+ let y = activeState ? activeState.y + activeState.height : headerRowHeight.value
// Adjust y position if fill handler is in the same active cell and multiple rows are selected
if (y === fillHandler.y) y -= fillHandler.size / 2
@@ -483,13 +486,19 @@ export function useCanvasRender({
// Draw line below the fill handler
ctx.beginPath()
ctx.moveTo(xOffset - scrollLeft.value, fillHandler.y + fillHandler.size / 2)
- ctx.lineTo(xOffset - scrollLeft.value, (rowSlice.value.end - rowSlice.value.start + 1) * rowHeight.value + 32)
+ ctx.lineTo(
+ xOffset - scrollLeft.value,
+ (rowSlice.value.end - rowSlice.value.start + 1) * rowHeight.value + headerRowHeight.value,
+ )
ctx.stroke()
} else if (activeState?.y && activeState?.height) {
// Draw line below active state
ctx.beginPath()
ctx.moveTo(xOffset - scrollLeft.value, activeState.y + activeState.height)
- ctx.lineTo(xOffset - scrollLeft.value, (rowSlice.value.end - rowSlice.value.start + 1) * rowHeight.value + 32)
+ ctx.lineTo(
+ xOffset - scrollLeft.value,
+ (rowSlice.value.end - rowSlice.value.start + 1) * rowHeight.value + headerRowHeight.value,
+ )
ctx.stroke()
}
} else if (visibleCols.filter((f) => !f.fixed).length) {
@@ -498,7 +507,7 @@ export function useCanvasRender({
const verticalLineXOffset = Math.max(fixedColsWidth.value, xOffset - scrollLeft.value)
ctx.strokeStyle = '#f4f4f5'
ctx.beginPath()
- ctx.moveTo(verticalLineXOffset, 32)
+ ctx.moveTo(verticalLineXOffset, headerRowHeight.value)
ctx.lineTo(
verticalLineXOffset,
(rowSlice.value.end - rowSlice.value.start + 1) * rowHeight.value + 33 - partialRowHeight.value,
@@ -528,14 +537,14 @@ export function useCanvasRender({
// Background
ctx.fillStyle = '#f4f4f5'
- ctx.fillRect(xOffset, 0, width, 32)
+ ctx.fillRect(xOffset, 0, width, headerRowHeight.value)
if (column.columnObj?.id) {
const columnState = isColumnSortedOrFiltered(column.columnObj.id, true)
if (columnState) {
renderTag(ctx, {
- height: 31.5,
+ height: headerRowHeight.value - 0.5,
width,
x: xOffset,
y: 0,
@@ -544,7 +553,7 @@ export function useCanvasRender({
})
renderTag(ctx, {
- height: 32,
+ height: headerRowHeight.value,
width,
x: xOffset,
y: 0,
@@ -566,7 +575,7 @@ export function useCanvasRender({
size: 13,
color: iconConfig?.hex ?? '#6a7184',
x: xOffset + 8,
- y: 8,
+ y: headerRowHeight.value / 2 - 7,
})
}
@@ -576,13 +585,14 @@ export function useCanvasRender({
const truncatedText = truncateText(ctx, column.title!, availableTextWidth)
const x = xOffset + (column.uidt ? 26 : 10)
- const y = 16
+ const y = headerRowHeight.value / 2
if (column.id === 'row_number') {
if (
!readOnly.value &&
!isMobileMode.value &&
- (isSelectedAllRecords.value || isBoxHovered({ x: 0, y: 0, width: canvasWidth, height: 32 }, mousePosition)) &&
+ (isSelectedAllRecords.value ||
+ isBoxHovered({ x: 0, y: 0, width: canvasWidth, height: headerRowHeight.value }, mousePosition)) &&
!isGroupBy.value
) {
const checkSize = 16
@@ -606,7 +616,7 @@ export function useCanvasRender({
if (isRequired) {
ctx.save()
ctx.fillStyle = '#EF4444'
- ctx.fillText('*', xOffset + 28 + ctx.measureText(truncatedText).width, 16)
+ ctx.fillText('*', xOffset + 28 + ctx.measureText(truncatedText).width, headerRowHeight.value / 2)
ctx.restore()
}
}
@@ -621,7 +631,7 @@ export function useCanvasRender({
size: 14,
color: '#6a7184',
x: rightOffset,
- y: 9,
+ y: y - 7,
})
} else if (meta.value?.synced && colObj?.readonly) {
rightOffset -= 16
@@ -630,7 +640,7 @@ export function useCanvasRender({
size: 14,
color: '#6a7184',
x: rightOffset,
- y: 9,
+ y: y - 7,
})
}
@@ -642,7 +652,7 @@ export function useCanvasRender({
size: 14,
color: '#FF928C',
x: rightOffset,
- y: 9,
+ y: y - 7,
})
}
@@ -654,14 +664,15 @@ export function useCanvasRender({
size: 13,
color: '#6B7280',
x: rightOffset,
- y: 9,
+ y: y - 7,
})
}
xOffset += width
// Border
const resizeHandleWidth = 10
- const isNearEdge = mousePosition && Math.abs(xOffset - mousePosition.x) <= resizeHandleWidth && mousePosition.y <= 32
+ const isNearEdge =
+ mousePosition && Math.abs(xOffset - mousePosition.x) <= resizeHandleWidth && mousePosition.y <= headerRowHeight.value
// Right border for row number field
if (column.id === 'row_number') {
@@ -669,7 +680,7 @@ export function useCanvasRender({
ctx.lineWidth = 2
ctx.beginPath()
ctx.moveTo(xOffset, 0)
- ctx.lineTo(xOffset, 32)
+ ctx.lineTo(xOffset, headerRowHeight.value)
ctx.stroke()
}
@@ -679,7 +690,7 @@ export function useCanvasRender({
ctx.lineWidth = 2
ctx.beginPath()
ctx.moveTo(xOffset, 0)
- ctx.lineTo(xOffset, 32)
+ ctx.lineTo(xOffset, headerRowHeight.value)
ctx.stroke()
// Reset for regular column separator
@@ -695,18 +706,18 @@ export function useCanvasRender({
ctx.beginPath()
ctx.lineWidth = 1
ctx.moveTo(xOffset, 0)
- ctx.lineTo(xOffset, isGroupBy.value ? height.value : 32)
+ ctx.lineTo(xOffset, isGroupBy.value ? height.value : headerRowHeight.value)
ctx.stroke()
ctx.fillStyle = 'rgba(0, 0, 0, 0.04)'
- ctx.rect(xOffset, 0, 4, isGroupBy.value ? height.value : 32)
+ ctx.rect(xOffset, 0, 4, isGroupBy.value ? height.value : headerRowHeight.value)
ctx.fill()
} else {
ctx.strokeStyle = '#E7E7E9'
ctx.beginPath()
ctx.lineWidth = 1
ctx.moveTo(xOffset, 0)
- ctx.lineTo(xOffset, isGroupBy.value ? height.value : 32)
+ ctx.lineTo(xOffset, isGroupBy.value ? height.value : headerRowHeight.value)
ctx.stroke()
}
ctx.shadowColor = 'transparent'
@@ -835,10 +846,11 @@ export function useCanvasRender({
groupPath,
selection.value.start.row,
rowHeight.value,
+ headerRowHeight.value,
isAddingEmptyRowAllowed.value,
) -
scrollTop.value +
- COLUMN_HEADER_HEIGHT_IN_PX
+ headerRowHeight.value
ctx.setLineDash([2, 2])
ctx.strokeStyle = isAiFillMode.value ? '#9751d7' : '#3366ff'
@@ -1655,7 +1667,7 @@ export function useCanvasRender({
const startRowIndex = Math.floor(scrollTop.value / rowHeight.value)
const visibleCols = columns.value.slice(startColIndex, endColIndex)
- let yOffset = -partialRowHeight.value + 33
+ let yOffset = -partialRowHeight.value + headerRowHeight.value + 1
let activeState: {
col: any
@@ -1769,18 +1781,18 @@ export function useCanvasRender({
{
x: 0,
y: yOffset,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
width: adjustedWidth,
},
mousePosition,
)
ctx.fillStyle = isNewRowHovered && isAddingEmptyRowPermitted.value ? '#F9F9FA' : '#ffffff'
- ctx.fillRect(0, yOffset, adjustedWidth, COLUMN_HEADER_HEIGHT_IN_PX)
+ ctx.fillRect(0, yOffset, adjustedWidth, headerRowHeight.value)
// Bottom border for new row
ctx.strokeStyle = '#f4f4f5'
ctx.beginPath()
- ctx.moveTo(0, yOffset + COLUMN_HEADER_HEIGHT_IN_PX)
- ctx.lineTo(adjustedWidth, yOffset + COLUMN_HEADER_HEIGHT_IN_PX)
+ ctx.moveTo(0, yOffset + headerRowHeight.value)
+ ctx.lineTo(adjustedWidth, yOffset + headerRowHeight.value)
ctx.stroke()
spriteLoader.renderIcon(ctx, {
@@ -1800,7 +1812,7 @@ export function useCanvasRender({
x: 0,
y: yOffset,
width: adjustedWidth,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
targetWidth: 258,
},
})
@@ -1810,7 +1822,7 @@ export function useCanvasRender({
elementMap.addElement({
y: yOffset,
x: 0,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
path: [],
type: ElementTypes.ADD_NEW_ROW,
})
@@ -2292,13 +2304,20 @@ export function useCanvasRender({
let targetRowLine
if (isGroupBy.value) {
targetRowLine =
- calculateGroupRowTop(cachedGroups.value, path, targetRowIndex.value, rowHeight.value, isAddingEmptyRowAllowed.value) -
+ calculateGroupRowTop(
+ cachedGroups.value,
+ path,
+ targetRowIndex.value,
+ rowHeight.value,
+ headerRowHeight.value,
+ isAddingEmptyRowAllowed.value,
+ ) -
scrollTop.value +
// add column header height since it's not included
- COLUMN_HEADER_HEIGHT_IN_PX
+ headerRowHeight.value
} else {
targetRowLine =
- (targetRowIndex.value - rowSlice.value.start) * rowHeight.value - partialRowHeight.value + COLUMN_HEADER_HEIGHT_IN_PX
+ (targetRowIndex.value - rowSlice.value.start) * rowHeight.value - partialRowHeight.value + headerRowHeight.value
}
// First render the blue line indicator
@@ -2479,7 +2498,7 @@ export function useCanvasRender({
{
x: 0,
y: yOffset,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
width: adjustedWidth,
},
mousePosition,
@@ -2489,7 +2508,7 @@ export function useCanvasRender({
level * 13,
yOffset,
adjustedWidth + 2,
- COLUMN_HEADER_HEIGHT_IN_PX,
+ headerRowHeight.value,
{
bottomLeft: 8,
bottomRight: 8,
@@ -2517,7 +2536,7 @@ export function useCanvasRender({
x: 16 + 20 + level * 13,
y: yOffset + 2,
fontFamily: '600 13px Inter',
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
fillStyle: '#374151',
text: `${t('activity.newRecord')}`,
})
@@ -2538,7 +2557,7 @@ export function useCanvasRender({
rect: {
x: level * 13,
y: yOffset,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
width: adjustedWidth,
targetWidth: 258,
},
@@ -2551,7 +2570,7 @@ export function useCanvasRender({
width: 16,
group,
level,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
path: group.nestedIn,
groupPath: group?.path,
type: ElementTypes.EDIT_NEW_ROW_METHOD,
@@ -2563,14 +2582,14 @@ export function useCanvasRender({
x: level * 13,
group,
level,
- height: COLUMN_HEADER_HEIGHT_IN_PX,
+ height: headerRowHeight.value,
path: group.nestedIn,
groupPath: group?.path,
type: ElementTypes.ADD_NEW_ROW,
})
}
- yOffset += COLUMN_HEADER_HEIGHT_IN_PX
+ yOffset += headerRowHeight.value
}
if (warningRow) {
@@ -2706,7 +2725,7 @@ export function useCanvasRender({
missingChunks.push(i)
}
const groupHeaderY = currentOffset
- const groupHeight = calculateGroupHeight(group, rowHeight.value, isAddingEmptyRowAllowed.value)
+ const groupHeight = calculateGroupHeight(group, rowHeight.value, headerRowHeight.value, isAddingEmptyRowAllowed.value)
const groupBottom = groupHeaderY + groupHeight
// Skip if group is fully outside viewport
@@ -2743,7 +2762,7 @@ export function useCanvasRender({
// If the group is at top, then use startIndex, else use endIndex
const gHeight = Array.from({ length: startIndex }, (_, g) => {
const group = groups.get(g)
- return calculateGroupHeight(group!, rowHeight.value, isAddingEmptyRowAllowed.value)
+ return calculateGroupHeight(group!, rowHeight.value, headerRowHeight.value, isAddingEmptyRowAllowed.value)
}).reduce((sum, c) => sum + c, 0)
// todo: figure out the 2px difference which is not expected
@@ -2782,7 +2801,7 @@ export function useCanvasRender({
const nestedStart = Math.min(
group.count,
// Use the negative offset to calculate the start index, as it helps determine how many rows are hidden
- Math.max(0, Math.floor(-(groupHeaderY + GROUP_HEADER_HEIGHT - COLUMN_HEADER_HEIGHT_IN_PX) / itemHeight)),
+ Math.max(0, Math.floor(-(groupHeaderY + GROUP_HEADER_HEIGHT - headerRowHeight.value) / itemHeight)),
)
// Calculate number of visible rows based on viewport height
const visibleRowCount = Math.ceil(viewportHeight / itemHeight)
@@ -2807,6 +2826,7 @@ export function useCanvasRender({
group.groups,
relativeScrollTop,
rowHeight.value,
+ headerRowHeight.value,
group.groupCount,
height.value - groupHeaderY - GROUP_HEADER_HEIGHT - GROUP_EXPANDED_BOTTOM_PADDING,
true,
@@ -2877,7 +2897,7 @@ export function useCanvasRender({
const isHovered = isBoxHovered(
{
x: aggXOffset - scrollLeft.value,
- y: Math.max(currentOffset, COLUMN_HEADER_HEIGHT_IN_PX) + 1,
+ y: Math.max(currentOffset, headerRowHeight.value) + 1,
width,
height: GROUP_HEADER_HEIGHT - 1 + (group?.isExpanded && !group?.path ? GROUP_EXPANDED_BOTTOM_PADDING : 0),
},
@@ -3349,6 +3369,7 @@ export function useCanvasRender({
cachedGroups.value,
scrollTop.value,
rowHeight.value,
+ headerRowHeight.value,
totalGroups.value,
height.value,
false,
@@ -3378,7 +3399,7 @@ export function useCanvasRender({
// render the active cell state and clip the header and aggregation footer areas
ctx.beginPath()
- ctx.rect(0, COLUMN_HEADER_HEIGHT_IN_PX, totalWidth.value, height.value - COLUMN_HEADER_HEIGHT_IN_PX - AGGREGATION_HEIGHT)
+ ctx.rect(0, headerRowHeight.value, totalWidth.value, height.value - headerRowHeight.value - AGGREGATION_HEIGHT)
ctx.clip()
postRenderCbk?.()
ctx.restore()
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasTable.ts b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasTable.ts
index fd45feaeb5..d47ca6df9e 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasTable.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasTable.ts
@@ -314,6 +314,8 @@ export function useCanvasTable({
const partialRowHeight = computed(() => scrollTop.value % rowHeight.value)
+ const headerRowHeight = computed(() => (isMobileMode.value ? 40 : COLUMN_HEADER_HEIGHT_IN_PX))
+
const isAiFillMode = computed(() => (isMac() ? !!metaKey?.value : !!ctrlKey?.value) && isAiFeaturesEnabled.value)
const fetchMetaIds = ref<string[][]>([])
@@ -667,9 +669,16 @@ export function useCanvasTable({
function getCellPosition(targetColumn: CanvasGridColumn, rowIndex: number, path: Array<number> = []) {
const yOffset =
- calculateGroupRowTop(cachedGroups.value, path, rowIndex, rowHeight.value, isAddingEmptyRowAllowed.value) -
+ calculateGroupRowTop(
+ cachedGroups.value,
+ path,
+ rowIndex,
+ rowHeight.value,
+ headerRowHeight.value,
+ isAddingEmptyRowAllowed.value,
+ ) -
scrollTop.value +
- COLUMN_HEADER_HEIGHT_IN_PX
+ headerRowHeight.value
if (targetColumn.fixed) {
let xOffset = 0
for (let i = 0; i < columns.value.length; i++) {
@@ -779,10 +788,11 @@ export function useCanvasTable({
groupPath,
selection.value.end.row,
rowHeight.value,
+ headerRowHeight.value,
isAddingEmptyRowAllowed.value,
) -
scrollTop.value +
- COLUMN_HEADER_HEIGHT_IN_PX +
+ headerRowHeight.value +
rowHeight.value
// const startY = -partialRowHeight.value + 33 + (selection.value.end.row - rowSlice.value.start + 1) * rowHeight.value
@@ -821,6 +831,7 @@ export function useCanvasTable({
totalGroups,
rowSlice,
rowHeight,
+ headerRowHeight,
activeCell,
dragOver,
hoverRow,
@@ -1210,8 +1221,14 @@ export function useCanvasTable({
if (isGroupBy.value && !path && !path?.legth) return
const yOffset =
- calculateGroupRowTop(cachedGroups.value, path, rowIndex, rowHeight.value, isAddingEmptyRowAllowed.value) +
- COLUMN_HEADER_HEIGHT_IN_PX
+ calculateGroupRowTop(
+ cachedGroups.value,
+ path,
+ rowIndex,
+ rowHeight.value,
+ headerRowHeight.value,
+ isAddingEmptyRowAllowed.value,
+ ) + headerRowHeight.value
let xOffset = (groupByColumns.value?.length ?? 0) * 13
const columnIndex = columns.value.findIndex((col) => col.id === clickedColumn.id)
@@ -1383,6 +1400,7 @@ export function useCanvasTable({
activeCell,
editEnabled,
rowHeight,
+ headerRowHeight,
totalWidth,
columnWidths,
columns,
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
index 0265e17d34..399045dcef 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
@@ -28,7 +28,6 @@ import { MouseClickType, NO_EDITABLE_CELL, getMouseClickType, parseCellWidth } f
import {
ADD_NEW_COLUMN_WIDTH,
AGGREGATION_HEIGHT,
- COLUMN_HEADER_HEIGHT_IN_PX,
GROUP_HEADER_HEIGHT,
GROUP_PADDING,
MAX_SELECTED_ROWS,
@@ -273,7 +272,6 @@ let colAutoScrollTimerId: any = null
const {
isGroupBy,
-
rowSlice,
colSlice,
editEnabled,
@@ -281,6 +279,7 @@ const {
totalWidth,
columnWidths,
rowHeight,
+ headerRowHeight,
updateVisibleRows,
columns,
findColumnIndex,
@@ -476,7 +475,7 @@ const isClamped = computed(() => {
}
const rawTop = editEnabled.value.y - scrollTop.value - rowHeight.value + 1
- const clampedTop = Math.max(32, Math.min(containerRef.value.clientHeight - rowHeight.value - 36, rawTop))
+ const clampedTop = Math.max(headerRowHeight.value, Math.min(containerRef.value.clientHeight - rowHeight.value - 36, rawTop))
const verticalStuck = clampedTop !== rawTop
let horizontalStuck = false
@@ -506,7 +505,7 @@ const editEnabledCellPosition = computed(() => {
}
const top = Math.max(
- COLUMN_HEADER_HEIGHT_IN_PX - 1,
+ headerRowHeight.value - 1,
Math.min(
containerRef.value?.clientHeight - rowHeight.value - AGGREGATION_HEIGHT,
editEnabled.value.y - scrollTop.value - rowHeight.value,
@@ -532,7 +531,7 @@ const totalHeight = computed(() => {
// For non-grouped view, use original calculation
if (!isGroupBy.value) {
const dataCache = getDataCache()
- return dataCache.totalRows.value * rowHeight.value + 32 + additionalPadding
+ return dataCache.totalRows.value * rowHeight.value + headerRowHeight.value + additionalPadding
}
// Add height for all top-level groups
@@ -548,7 +547,7 @@ const totalHeight = computed(() => {
sum += group.count * rowHeight.value
if (isAddingEmptyRowAllowed.value && !removeInlineAddRecord.value) {
- sum += COLUMN_HEADER_HEIGHT_IN_PX
+ sum += headerRowHeight.value
}
// 1 Px Offset is Added for Showing the activeBorders. Else it wont be visible
sum += 1
@@ -562,7 +561,7 @@ const totalHeight = computed(() => {
return sum
}
- return rootGroupsHeight + estimateTotalHeight(cachedGroups.value) + 32 + additionalPadding // Additional padding
+ return rootGroupsHeight + estimateTotalHeight(cachedGroups.value) + headerRowHeight.value + additionalPadding // Additional padding
})
const isContextMenuOpen = computed({
@@ -1037,7 +1036,7 @@ async function handleMouseDown(e: MouseEvent) {
const clickType = getMouseClickType(e)
if (!clickType) return
// Handle all Column Header Operations
- if (y <= COLUMN_HEADER_HEIGHT_IN_PX) {
+ if (y <= headerRowHeight.value) {
// If x less than 80px, use is hovering over the row meta column
if (x > rowMetaColumnWidth.value) {
// If the user is trying to resize the column
@@ -1249,7 +1248,7 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
if (editEnabled.value) return
if (onMouseUpSelectionHandler(e)) {
- if (y <= COLUMN_HEADER_HEIGHT_IN_PX || y > height.value - 36 || x <= rowMetaColumnWidth.value) {
+ if (y <= headerRowHeight.value || y > height.value - 36 || x <= rowMetaColumnWidth.value) {
// DO_NOTHING_HERE
} else {
requestAnimationFrame(triggerRefreshCanvas)
@@ -1262,7 +1261,7 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
if (!clickType) return
if (isMobileMode.value) {
- if (y > 32 && y < height.value - 36) {
+ if (y > headerRowHeight.value && y < height.value - 36) {
const element = _elementMap.findElementAt(x, y, [ElementTypes.ROW, ElementTypes.GROUP, ElementTypes.ADD_NEW_ROW])
const group = element?.group
const row = element?.row
@@ -1277,12 +1276,12 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
}
requestAnimationFrame(triggerRefreshCanvas)
return
- } else if (y < 32) {
+ } else if (y < headerRowHeight.value) {
return
}
}
// Handle all Column Header Operations
- if (y <= COLUMN_HEADER_HEIGHT_IN_PX) {
+ if (y <= headerRowHeight.value) {
// If x less than 80px, use is hovering over the row meta column
if (x < rowMetaColumnWidth.value + groupByColumns.value.length * 13) {
// If the click is not normal single click, return
@@ -1316,7 +1315,7 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
top: `${rect.top}px`,
left: `${plusColumnX + rect.left}px`,
width: `${plusColumnWidth}px`,
- height: '32px',
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
isDropdownVisible.value = true
@@ -1340,7 +1339,7 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
top: `${rect.top}px`,
left: `${rect.left + xOffset}px`,
width: `${clickedColumn.width}`,
- height: `32px`,
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
requestAnimationFrame(triggerRefreshCanvas)
@@ -1371,7 +1370,7 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
top: `${rect.top}px`,
left: `${rect.left + xOffset}px`,
width: `${clickedColumn.width}`,
- height: `32px`,
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
openColumnDropdownField.value = clickedColumn.columnObj
@@ -1848,7 +1847,7 @@ const handleMouseMove = (e: MouseEvent) => {
hideTooltip()
const fixedCols = columns.value.filter((col) => col.fixed)
- if (mousePosition.y < 32) {
+ if (mousePosition.y < headerRowHeight.value) {
// check if it's hovering add new column
const plusColumnX = totalColumnsWidth.value - scrollLeft.value + groupByColumns.value?.length * 13
const plusColumnWidth = ADD_NEW_COLUMN_WIDTH
@@ -1979,7 +1978,7 @@ const handleMouseMove = (e: MouseEvent) => {
}
} else {
const y = e.clientY - rect.top
- if (y <= 32 && resizeableColumn.value) {
+ if (y <= headerRowHeight.value && resizeableColumn.value) {
resizeMouseMove(e)
} else if (mousePosition.y > height.value - 36) {
cursor = mousePosition.x < totalColumnsWidth.value - scrollLeft.value ? 'pointer' : 'auto'
@@ -2007,7 +2006,7 @@ const handleMouseMove = (e: MouseEvent) => {
}
requestAnimationFrame(triggerRefreshCanvas)
}
- if (mousePosition.y > 32) {
+ if (mousePosition.y > headerRowHeight.value) {
const element = elementMap.findElementAt(mousePosition.x, mousePosition.y, [ElementTypes.ADD_NEW_ROW, ElementTypes.ROW])
const row = element?.row
const rowIndex = element?.rowIndex
@@ -2040,10 +2039,7 @@ const handleMouseMove = (e: MouseEvent) => {
if (cursor) setCursor(cursor)
// check if hovering row meta column and set cursor
- if (
- mousePosition.x < rowMetaColumnWidth.value + groupByColumns.value.length * 13 &&
- mousePosition.y > COLUMN_HEADER_HEIGHT_IN_PX
- ) {
+ if (mousePosition.x < rowMetaColumnWidth.value + groupByColumns.value.length * 13 && mousePosition.y > headerRowHeight.value) {
// handle hovering on the aggregation dropdown
if (mousePosition.y <= height.value - 36) {
const element = elementMap.findElementAt(mousePosition.x, mousePosition.y, [ElementTypes.ADD_NEW_ROW, ElementTypes.ROW])
@@ -2170,7 +2166,7 @@ const handleScroll = (e: { left: number; top: number }) => {
if (!rect) return
// TODO: @DarkPhoenix2704
- // hoverRow.value = Math.floor(scrollTop.value / rowHeight.value + (mousePosition.y - 32) / rowHeight.value)
+ // hoverRow.value = Math.floor(scrollTop.value / rowHeight.value + (mousePosition.y - headerRowHeight.value) / rowHeight.value)
requestAnimationFrame(triggerRefreshCanvas)
}, 150)
}
@@ -2251,7 +2247,7 @@ function addEmptyColumn(columnOrderData: Pick<ColumnReqType, 'column_order'> | n
top: `${rect.top}px`,
right: `${256 - ADD_NEW_COLUMN_WIDTH}px`,
width: `${ADD_NEW_COLUMN_WIDTH}px`,
- height: '32px',
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
@@ -2282,7 +2278,7 @@ function handleEditColumn(_e: MouseEvent, isDescription = false, column: ColumnT
top: `${rect.top}px`,
left: `${rect.left + (clickedXOffset ?? xOffset)}px`,
width: col?.width ?? '180px',
- height: `32px`,
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
@@ -2310,7 +2306,7 @@ function openColumnCreate(data: any) {
top: `${rect.top}px`,
left: `${plusColumnX + rect.left}px`,
width: `${ADD_NEW_COLUMN_WIDTH}px`,
- height: '32px',
+ height: `${headerRowHeight.value}px`,
position: 'fixed',
}
@@ -2706,7 +2702,7 @@ const onOver = (_files: File[] | null, e: DragEvent) => {
mousePosition.y = e.clientY - rect.top
// Skip on hover on header
- if (mousePosition.y <= 32) {
+ if (mousePosition.y <= headerRowHeight.value) {
return resetAttachmentCellDropOver()
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/utils/groupby.ts b/packages/nc-gui/components/smartsheet/grid/canvas/utils/groupby.ts
index 28eb280c06..fd7333739b 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/utils/groupby.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/utils/groupby.ts
@@ -1,5 +1,5 @@
import { UITypes, isLinksOrLTAR } from 'nocodb-sdk'
-import { COLUMN_HEADER_HEIGHT_IN_PX, GROUP_EXPANDED_BOTTOM_PADDING, GROUP_HEADER_HEIGHT, GROUP_PADDING } from './constants'
+import { GROUP_EXPANDED_BOTTOM_PADDING, GROUP_HEADER_HEIGHT, GROUP_PADDING } from './constants'
export function getGroupColors(depth: number, maxDepth: number) {
depth = depth + 1
@@ -117,13 +117,18 @@ export function getBackgroundColor(depth: number, maxDepth: number): string {
return '#F9F9FA'
}
-export function calculateGroupHeight(group: CanvasGroup, rowHeight: number, isAddingNewRowAllowed?: boolean) {
+export function calculateGroupHeight(
+ group: CanvasGroup,
+ rowHeight: number,
+ headerRowHeight: number,
+ isAddingNewRowAllowed?: boolean,
+) {
let h = GROUP_HEADER_HEIGHT + GROUP_PADDING // Base height for group header
if (group?.isExpanded) {
if (group.path) {
h += (group.count || 0) * rowHeight
if (isAddingNewRowAllowed) {
- h += COLUMN_HEADER_HEIGHT_IN_PX
+ h += headerRowHeight
}
// 1 Px Offset is Added for Showing the activeBorders. Else it wont be visible
h += 1
@@ -136,7 +141,7 @@ export function calculateGroupHeight(group: CanvasGroup, rowHeight: number, isAd
h += GROUP_HEADER_HEIGHT + GROUP_PADDING
continue
}
- h += calculateGroupHeight(subGroup, rowHeight, isAddingNewRowAllowed) // Recursively calculate subgroup height
+ h += calculateGroupHeight(subGroup, rowHeight, headerRowHeight, isAddingNewRowAllowed) // Recursively calculate subgroup height
}
}
}
@@ -147,6 +152,7 @@ export function calculateGroupRange(
groups: Map<number, CanvasGroup>,
scrollTop: number,
rowHeight: number,
+ headerRowHeight: number,
groupCount: number,
viewportHeight: number,
_nested = false,
@@ -159,13 +165,13 @@ export function calculateGroupRange(
for (let i = 0; i < groupCount; i++) {
const group = groups.get(i)
- const groupHeight = calculateGroupHeight(group, rowHeight, isAddingNewRowAllowed)
+ const groupHeight = calculateGroupHeight(group, rowHeight, headerRowHeight, isAddingNewRowAllowed)
if (currentOffset + groupHeight >= scrollTop) {
startIndex = i
// startGroupYOffset - is the offset of the group from the top of the viewport, this could be negative
// when the group is partially visible at the top of the viewport
// excluding column header height from the calculation since it will be sticky on top
- const startGroupYOffset = COLUMN_HEADER_HEIGHT_IN_PX - (scrollTop - currentOffset)
+ const startGroupYOffset = headerRowHeight - (scrollTop - currentOffset)
// todo: verify - GROUP_HEADER_HEIGHT + GROUP_PADDING addition
// it's added to render one extra group at the bottom of the viewport to avoid empty space
@@ -173,7 +179,7 @@ export function calculateGroupRange(
for (let j = i; j < groupCount; j++) {
const endGroup = groups.get(j)
- const endGroupHeight = calculateGroupHeight(endGroup, rowHeight, isAddingNewRowAllowed)
+ const endGroupHeight = calculateGroupHeight(endGroup, rowHeight, headerRowHeight, isAddingNewRowAllowed)
if (currentOffset + endGroupHeight > viewportBottom) {
endIndex = j
break
@@ -219,6 +225,7 @@ export function calculateGroupRowTop(
path: number[],
rowIndex: number,
rowHeight: number,
+ headerRowHeight: number,
isAddingEmptyRowAllowed: boolean,
): number {
let top = GROUP_PADDING
@@ -236,7 +243,7 @@ export function calculateGroupRowTop(
for (let i = 0; i < groupIndex; i++) {
const siblingGroup = currentGroups.get(i)
if (siblingGroup) {
- top += calculateGroupHeight(siblingGroup, rowHeight, isAddingEmptyRowAllowed)
+ top += calculateGroupHeight(siblingGroup, rowHeight, headerRowHeight, isAddingEmptyRowAllowed)
}
}