Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
smason0 committed Oct 23, 2023
1 parent cbf9f3c commit 832197d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/terra-data-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Added
* Added "No result" cells to FlowsheetDataGrid.

## 0.8.1 - (October 17, 2023)

* Fixed
Expand All @@ -14,7 +17,6 @@

* Added
* Added base FlowsheetDataGrid component.
* Added "No result" cells to FlowsheetDataGrid.

* Changed
* Updated prop descriptions for better consistency and accuracy in the `terra-data-grid` component.
Expand Down
6 changes: 4 additions & 2 deletions packages/terra-data-grid/src/FlowsheetDataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ function FlowsheetDataGrid(props) {
const pinnedColumns = flowsheetColumns.length ? [flowsheetColumns[0]] : [];
const overflowColumns = flowsheetColumns.length > 1 ? flowsheetColumns.slice(1) : [];

const contentHasNoResult = (content) => (content === null || content === '' || content === '--');

const flowsheetRows = useMemo(() => {
const noResultCellContent = (
<>
Expand All @@ -114,8 +116,8 @@ function FlowsheetDataGrid(props) {
newRows.forEach((row, rowIndex) => {
const newCells = [...row.cells];
newCells.forEach((cell, cellIndex) => {
// Cell has no content and is not a row header (first column), set content to "No result".
if (!cell.content && cellIndex !== 0) {
// Cell content has no result and is not a row header (first column), set content to "No result".
if (contentHasNoResult(cell.content) && cellIndex !== 0) {
newCells[cellIndex].content = noResultCellContent;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('FlowsheetDataGrid', () => {
id: '3',
cells: [
{ content: 'Cardiac Index (L/min/m2)' },
{ content: undefined },
{ content: '' },
{ content: '2.28' },
],
},
Expand All @@ -162,7 +162,7 @@ describe('FlowsheetDataGrid', () => {
cells: [
{ content: '' },
{ content: null },
{ content: undefined },
{ content: '--' },
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { FlowsheetDataGrid } from 'terra-data-grid';
## Examples
<BasicFlowsheetDataGrid title= 'Basic Flowsheet Data Grid' />
<FlowsheetDataGridResultsMissing
title= 'Flowsheet Data Grid with Results Missing'
title= 'Flowsheet Data Grid with "No Result" Cells'
description= 'If the content of a cell is empty or missing, it will be represented by a dash. This is interpreted by assistive technology as "No result."'
/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import FlowsheetDataGridResultsMissing from './FlowsheetDataGridResultsMissing?dev-site-example';

<FlowsheetDataGridResultsMissing title='Flowsheet Data Grid with Results Missing' />
<FlowsheetDataGridResultsMissing
title= 'Flowsheet Data Grid with "No Result" Cells'
description= 'If the content of a cell is empty or missing, it will be represented by a dash. This is interpreted by assistive technology as "No result."'
/>

0 comments on commit 832197d

Please sign in to comment.