Skip to content

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

fix(nc-gui): add ellipsis if lookup next line has some items

Ramesh Manee1027d8f2b5a
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Lookup.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Lookup.ts
index 7d8d4b6018..706c95822e 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Lookup.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Lookup.ts
@@ -229,30 +229,57 @@ export const LookupCellRenderer: CellRenderer = {
for (const v of arrValue) {
const point = lookupRenderer({ ...renderProps, value: v, x, y, width })
- if (point?.x && !point?.nextLine) {
- if (point?.x >= _x + _width - padding * 2 - 50) {
+ if (renderOnly1Row.includes(lookupColumn.uidt)) {
+ if (point?.x) {
+ x = point?.x
+ }
+ } else if (point?.x && !point?.nextLine) {
+ if (point?.x >= _x + _width - padding * 4 - (line + 1 > maxLines && count < arrValue.length ? 50 - ellipsisWidth : 0)) {
+ if (line + 1 > maxLines || renderOnly1Row.includes(lookupColumn.uidt)) {
+ flag = true
+
+ if (point?.x) {
+ x = point?.x + padding
+ } else {
+ x = _x + _width - padding - ellipsisWidth
+ }
+
+ break
+ }
+
x = _x
- width = _width
+ width = _width - ellipsisWidth
y = point?.y && y !== point?.y && point?.y - y >= 24 ? point?.y : y + 24
line += 1
- if (renderOnly1Row.includes(lookupColumn.uidt)) break
} else {
width = _x + _width - (point?.x - 2 * 4) - padding * 2
x = point?.x
}
} else {
+ if (line + 1 > maxLines || renderOnly1Row.includes(lookupColumn.uidt)) {
+ if (!point?.nextLine) {
+ flag = true
+ }
+ break
+ }
+
x = _x
y += 24
width = _width
line += 1
- if (renderOnly1Row.includes(lookupColumn.uidt)) break
}
if (line > maxLines) {
+ flag = true
+
break
}
count++
}
+
+ if (flag && count < arrValue.length) {
+ handleRenderEllipsis()
+ }
}
if (isVirtualCol(lookupColumn) && ![UITypes.Rollup, UITypes.Formula].includes(lookupColumn.uidt)) {
diff --git a/packages/nc-gui/lib/types.ts b/packages/nc-gui/lib/types.ts
index 364f60e230..e264f728b8 100644
--- a/packages/nc-gui/lib/types.ts
+++ b/packages/nc-gui/lib/types.ts
@@ -521,7 +521,7 @@ type SetCursorType = (cursor: CursorType, customCondition?: (prevValue: CursorTy
type MakeCellEditableFn = (row: Row, clickedColumn: CanvasGridColumn, showEditCellRestrictionTooltip?: boolean) => void
interface CellRenderFn {
- (ctx: CanvasRenderingContext2D, options: CellRendererOptions): void | { x?: number; y?: number }
+ (ctx: CanvasRenderingContext2D, options: CellRendererOptions): void | { x?: number; y?: number; nextLine?: boolean }
}
interface CellRenderer {