Skip to content

Commit b219386

Browse files
committed
setup some overflow ellipsis
1 parent 0f2d50d commit b219386

2 files changed

Lines changed: 55 additions & 22 deletions

File tree

src/components/TableShared/EnhancedTable.jsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export const renderTableHeader = (headerGroups) => {
8484
...headerProps.style,
8585
width: column.width,
8686
minWidth: column.minWidth,
87-
maxWidth: column.width,
8887
position: "relative",
8988
}}
9089
>
@@ -138,7 +137,6 @@ export const renderTableHeader = (headerGroups) => {
138137
style={{
139138
width: column.width,
140139
minWidth: column.minWidth,
141-
maxWidth: column.width,
142140
}}
143141
>
144142
{column.canFilter && (
@@ -172,3 +170,37 @@ export const TableWrapper = ({ children, className = "" }) => (
172170
<div className="mr-inline-block mr-min-w-full">{children}</div>
173171
</div>
174172
);
173+
174+
/**
175+
* Renders a table cell with nowrap styling
176+
* @param {Object} cell - The react-table cell object
177+
* @param {Object} options - Additional styling options
178+
* @returns {JSX.Element} - The rendered table cell
179+
*/
180+
export const renderTableCell = (cell, options = {}) => {
181+
return (
182+
<td
183+
{...cell.getCellProps()}
184+
style={{
185+
...cell.getCellProps().style,
186+
whiteSpace: "nowrap !important",
187+
overflow: "hidden !important",
188+
textOverflow: "ellipsis !important",
189+
minWidth: cell.column.minWidth,
190+
...options,
191+
}}
192+
>
193+
<div
194+
style={{
195+
overflow: "hidden !important",
196+
textOverflow: "ellipsis !important",
197+
whiteSpace: "nowrap !important",
198+
width: "100%",
199+
display: "block",
200+
}}
201+
>
202+
{cell.render("Cell")}
203+
</div>
204+
</td>
205+
);
206+
};

src/components/TaskAnalysisTable/TaskAnalysisTable.jsx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ import WithLoadedTask from "../HOCs/WithLoadedTask/WithLoadedTask";
3333
import IntlDatePicker from "../IntlDatePicker/IntlDatePicker";
3434
import PaginationControl from "../PaginationControl/PaginationControl";
3535
import SvgSymbol from "../SvgSymbol/SvgSymbol";
36-
import { SearchFilter, TableWrapper, renderTableHeader } from "../TableShared/EnhancedTable";
37-
import { cellStyles, inputStyles, rowStyles, tableStyles } from "../TableShared/TableStyles";
36+
import {
37+
SearchFilter,
38+
TableWrapper,
39+
renderTableHeader,
40+
renderTableCell,
41+
} from "../TableShared/EnhancedTable";
42+
import { inputStyles, rowStyles, tableStyles } from "../TableShared/TableStyles";
3843
import ViewTask from "../ViewTask/ViewTask";
3944
import messages from "./Messages";
4045
import TaskAnalysisTableHeader from "./TaskAnalysisTableHeader";
@@ -285,22 +290,7 @@ export const TaskAnalysisTableInternal = (props) => {
285290
className={`${row.isExpanded ? "mr-bg-black-10" : ""} ${rowStyles}`}
286291
>
287292
{row.cells.map((cell) => {
288-
return (
289-
<td
290-
key={cell.column.id}
291-
{...cell.getCellProps()}
292-
className={cellStyles}
293-
style={{
294-
...cell.getCellProps().style,
295-
maxWidth: cell.column.width,
296-
minWidth: cell.column.minWidth,
297-
overflow: "hidden",
298-
height: "40px",
299-
}}
300-
>
301-
<div className="mr-cell-content">{cell.render("Cell")}</div>
302-
</td>
303-
);
293+
return renderTableCell(cell);
304294
})}
305295
</tr>
306296

@@ -389,7 +379,18 @@ const setupColumnTypes = (props, taskBaseRoute, manager, openComments) => {
389379
id: "featureId",
390380
Header: props.intl.formatMessage(messages.featureIdLabel),
391381
accessor: (t) => t.name || t.title,
392-
Cell: ({ value }) => value || "",
382+
Cell: ({ value }) => (
383+
<div
384+
style={{
385+
overflow: "hidden",
386+
whiteSpace: "nowrap",
387+
textOverflow: "ellipsis",
388+
width: "100%",
389+
}}
390+
>
391+
{value || ""}
392+
</div>
393+
),
393394
Filter: ({ column: { filterValue, setFilter } }) => (
394395
<div className="mr-flex mr-items-center" onClick={(e) => e.stopPropagation()}>
395396
<SearchFilter
@@ -486,6 +487,7 @@ const setupColumnTypes = (props, taskBaseRoute, manager, openComments) => {
486487
)}
487488
</div>
488489
),
490+
width: 40,
489491
};
490492

491493
columns.status = {
@@ -937,7 +939,6 @@ const setupColumnTypes = (props, taskBaseRoute, manager, openComments) => {
937939
accessor: "commentID",
938940
Cell: ({ row }) => <ViewCommentsButton onClick={() => openComments(row.original.id)} />,
939941
width: 110,
940-
941942
disableSortBy: true,
942943
};
943944

0 commit comments

Comments
 (0)