Skip to content

Commit

Permalink
feat(TableWidget): Implement cell wrapping functionality
Browse files Browse the repository at this point in the history
This commit adds cell wrapping support to the Table widget with the following changes:

- Add allowCellWrapping property that controls text wrapping behavior in table cells
- Update cell styling to use break-spaces and word-break when wrapping is enabled
- Adjust cell height calculations to accommodate wrapped content
- Disable virtual scrolling when any column has cell wrapping enabled for better rendering
- Update inline cell editor height to be dynamic when wrapping is enabled

Key changes:
- TableStyledWrappers.tsx: Add conditional cell wrapping styles (lines 579-588)
- InlineCellEditor.tsx: Update height calculation for wrapped cells (lines 49-62)
- Table.tsx: Disable virtual scrolling when cell wrapping is enabled (lines 330-334)
- PlainTextCell.tsx: Add content height detection for wrapped cells (lines 102-107)

This improves content visibility in table cells by allowing text to wrap instead of being truncated with ellipsis, while maintaining performance optimizations where possible.
  • Loading branch information
rahulbarwal committed Nov 29, 2024
1 parent 027db2d commit 14ce4cb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 61 deletions.
10 changes: 2 additions & 8 deletions app/client/src/widgets/TableWidgetV2/component/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import {
} from "./Constants";
import { Colors } from "constants/Colors";
import type { EventType } from "constants/AppsmithActionConstants/ActionConstants";
import {
ColumnTypes,
type EditableCell,
type TableVariant,
} from "../constants";
import { type EditableCell, type TableVariant } from "../constants";
import SimpleBar from "simplebar-react";
import "simplebar-react/dist/simplebar.min.css";
import { createGlobalStyle } from "styled-components";
Expand Down Expand Up @@ -330,9 +326,7 @@ export function Table(props: TableProps) {
const shouldUseVirtual =
props.serverSidePaginationEnabled &&
!props.columns.some(
(column) =>
!!column.columnProperties.allowCellWrapping ||
column.metaProperties?.type === ColumnTypes.HTML,
(column) => !!column.columnProperties.allowCellWrapping,
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,38 @@ import React, { useMemo } from "react";
import Interweave from "interweave";
import { UrlMatcher, EmailMatcher } from "interweave-autolink";
import styled from "styled-components";
import type { BaseCellComponentProps } from "../Constants";
import {
TABLE_SIZES,
type BaseCellComponentProps,
type CompactMode,
} from "../Constants";
import { CellWrapper } from "../TableStyledWrappers";
import LinkFilter from "widgets/TextWidget/component/filters/LinkFilter";
import { countOccurrences } from "workers/Evaluation/helpers";

const MAX_HTML_PARSING_LENGTH = 1000;

const HTMLContent = styled.div`
height: 100%;
const ContentWrapper = styled.div<{
allowCellWrapping?: boolean;
compactMode: CompactMode;
}>`
width: 100%;
overflow: hidden;
display: flex;
align-items: center;
ul {
list-style-type: disc;
list-style-position: inside;
}
ol {
list-style-type: decimal;
list-style-position: inside;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
h2 {
font-size: 1.5em;
margin: 0.75em 0;
}
h3 {
font-size: 1.17em;
margin: 0.83em 0;
}
h5 {
font-size: 0.83em;
margin: 1.5em 0;
}
h6 {
font-size: 0.75em;
margin: 1.67em 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: bold;
}
a {
color: #106ba3;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
${(props) =>
props.allowCellWrapping
? `
white-space: break-spaces;
word-break: break-word;
height: 100%;
`
: `
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: ${TABLE_SIZES[props.compactMode].ROW_HEIGHT}px};
`}
`;

export interface HTMLCellProps extends BaseCellComponentProps {
Expand Down Expand Up @@ -119,7 +92,10 @@ export function HTMLCell(props: HTMLCellProps) {
textSize={textSize}
verticalAlignment={verticalAlignment}
>
<HTMLContent>
<ContentWrapper
allowCellWrapping={allowCellWrapping}
compactMode={compactMode}
>
<Interweave
content={inteweaveCompatibleValue}
filters={[new LinkFilter()]}
Expand All @@ -130,7 +106,7 @@ export function HTMLCell(props: HTMLCellProps) {
}
newWindow
/>
</HTMLContent>
</ContentWrapper>
</CellWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default {
ColumnTypes.TEXT,
ColumnTypes.NUMBER,
ColumnTypes.URL,
ColumnTypes.HTML,
]);
},
},
Expand Down

0 comments on commit 14ce4cb

Please sign in to comment.