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

[terra-data-grid] DataGrid consumes Table #1851

Merged
merged 56 commits into from
Nov 7, 2023
Merged

Conversation

kenk2
Copy link
Contributor

@kenk2 kenk2 commented Oct 20, 2023

Summary

What was changed:
DataGrid consumes table.

Why it was changed:
To eliminate redundant code and follow the DataGrid roadmap

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-9543


Thank you for contributing to Terra.
@cerner/terra

Comment on lines -20 to -24
:focus {
outline: var(--terra-data-grid-cell-focus-outline, 3px dashed #000);
outline-offset: var(--terra-data-grid-cell-focus-outline-offset, -2px);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This focus selector should not have been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that this is still removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it turns out that this is in table, so we don't actually need this here after all.

/**
* Boolean specifying whether or not the component should have zebra striping for rows.
*/
isStriped: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a prop for the Flowsheet. The Flowsheet should always be striped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the striped logic out of the Flowsheet and WDG. Now only specified in DataGrid.

@@ -94,6 +101,7 @@ function FlowsheetDataGrid(props) {
id={id}
ariaLabel={ariaLabel}
ariaLabelledBy={ariaLabelledBy}
isStriped={isStriped}
Copy link
Contributor

@cm9361 cm9361 Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always be passing true. The logic should be done in the DataGrid component. We should not need this logic in either the WorklistDataGrid or Flowsheet components.

/**
* Boolean specifying whether or not the component should have zebra striping for rows.
*/
isStriped: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a prop for the WorklistDataGrid. The WorklistDataGrid should always be striped.

@@ -418,11 +425,26 @@ function WorklistDataGrid(props) {
id={id}
ariaLabel={ariaLabel}
ariaLabelledBy={ariaLabelledBy}
rows={rows}
isStriped={isStriped}
Copy link
Contributor

@cm9361 cm9361 Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value should always be true. The logic should be in the DataGrid component.

isSelectable: columns.isSelectable !== false,
isResizable: columns.isResizable !== false,
}))}
overflowColumns={overflowColumns.map((columns) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the iterator variable name be "column"? Isn't this an individual column that is being passed to the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created some mapper functions to apply this to Datagrid and WDG.

Comment on lines 429 to 435
rows={rows.map((row) => ({
...row,
cells: row.cells.map(cell => ({
...cell,
isSelectable: cell.isSelectable !== false,
})),
}))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better for maintenance if we create a function for this.

Comment on lines 444 to 446
...columns,
isSelectable: columns.isSelectable !== false,
isResizable: columns.isResizable !== false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are duplicating the same logic for columns. Maybe it should be a function.

Comment on lines 185 to 190
useEffect(() => {
if (pinnedColumns.length === 0) {
// eslint-disable-next-line no-console
console.warn(ERRORS.PINNED_COLUMNS_UNDEFINED);
}
}, [pinnedColumns.length]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would not want the update on the length of the columns. We just need it to update when pinnedColumns does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this and the sending of the cell coordinates.

@kenk2 kenk2 changed the title [terra-data-grid] [WIP] DataGrid consumes Table [terra-data-grid] DataGrid consumes Table Nov 7, 2023
@@ -5,6 +5,7 @@
* Fixed
* Fixed the column header background color for the Orion Fusion theme.
* Fixed pinned column divider issue during keyboard resize.
* Fixed left column header border for components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you rebase with main? This code should already be present and not show up as a change.

Copy link
Contributor Author

@kenk2 kenk2 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was not made in datagrid (which still has this bug), so I had to fix it in this PR. We're going to consume from table from now on so the fix was needed here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to update the data grid logic. We won't be using it.

@@ -9,19 +9,7 @@
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not expect the data-grid-container element to have an overflow. The Terra Table already had an element with an overflow.

Comment on lines 11 to 16
const TABLE_ROW_SELECTION_COLUMN = {
id: 'table-rowSelectionColumn',
width: 40,
isSelectable: true,
isResizable: false,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not need this logic. It is encapsulated in the Terra Table.

Comment on lines 18 to 21
const WorklistDataGridUtils = {
ROW_SELECTION_COLUMN,
TABLE_ROW_SELECTION_COLUMN,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this logic with the updated Terra Table?

Copy link
Contributor Author

@kenk2 kenk2 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do because we're using different ID's for the row selection column in each component. Table uses table-rowSelectionColumn while WDG uses worklistDataGrid-rowSelectionColumn. I also want to put this here because we reference this in multiple places so we don't have magic strings. I could however as an alternative, import this from terra table.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this entire structure just for an id.

Comment on lines 3 to 5
{ "id": "Column-0", "displayName": "Vitals", "isSelectable": true, "sortIndicator": "ascending", "isResizable": true },
{ "id": "Column-1", "displayName": "March 16", "isSelectable": true, "isResizable": true },
{ "id": "Column-2", "displayName": "March 17", "isSelectable": true },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this need to change for the Terra Table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just to provide a way for people to test column resizing and selectable columns in table.

@@ -42,6 +42,7 @@ const SortableTable = () => {
id="sortable-table"
overflowColumns={tableColumns}
rows={tableRows}
columnResizeIncrement={5}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not have required a change since we have a default value defined.

@@ -8,6 +8,7 @@

* Fixed
* Fixed the column header background color for the Orion Fusion theme.
* Fixed an issue with row selection integrating with table zebra stripes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not show up as your change.

@sdadn sdadn added ⭐ UX Reviewed UX Reviewed and approved. and removed UX Review Required labels Nov 7, 2023
Copy link
Contributor

github-actions bot commented Nov 7, 2023

Fails
🚫 Please include a CHANGELOG entry for each changed package this PR. Looks like a CHANGELOG entry is missing for:
  • terra-data-grid
  • terra-table

Generated by 🚫 dangerJS against 836168c

@kenk2
Copy link
Contributor Author

kenk2 commented Nov 7, 2023

Fails
🚫 Please include a CHANGELOG entry for each changed package this PR. Looks like a CHANGELOG entry is missing for:

  • terra-data-grid
  • terra-table

Generated by 🚫 dangerJS against c0e1e10

These do not involve consumer-facing changes. Therefore, no changelogs will be needed for these packages.

Comment on lines 496 to 501
<GridContext.Provider value={{
role: GridConstants.GRID,
setCellAriaLiveMessage,
tableRef: grid,
tableContainerRef,
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did not memoize your provider value. This will cause many unnecessary rerenders.

@@ -64,21 +66,22 @@ afterAll(() => {

describe('DataGrid', () => {
it('verifies that the grid created is consistent with the rows and overflowColumns props', () => {
const wrapper = shallowWithIntl(
const wrapper = mountWithIntl(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason these needed to be changed to mount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to make this work with the existing shallow render but was not able to find the components with shallow alone as Table is now embedded in a Host Component, thus making us unable to find the component without fully mounting it.

@github-actions github-actions bot temporarily deployed to preview-pr-1851 November 7, 2023 21:30 Destroyed
@kenk2 kenk2 merged commit 90010e6 into main Nov 7, 2023
0 of 20 checks passed
@kenk2 kenk2 deleted the data-grid-consumes-table branch November 7, 2023 21:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants