-
Notifications
You must be signed in to change notification settings - Fork 166
Conversation
…background color.
…e obsolete properties.
…o table for enabling column selections and callbacks. Add more examples for table.
…Fix some behavior with cells focusing after navigation.
…ble tables more interactable. Removed un-necessary ref initialization. Remove table container to handle scroll from consumers. Light refactor of pinned columns logic.
… focusing by keyboard.
columnHeaderHeight: '2.5rem', | ||
rowHeight: '2.5rem', | ||
pinnedColumns: [], | ||
overflowColumns: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a default empty array for rows
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now I'm requiring rows
to be supplied (but it can be empty) since in DataGrid this is actually a bug right now (component will not render otherwise). But I could also see a case where we might want to default to []
if rows
is not specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might suggest also making it optional if we allow rows
to be empty, as that puts less burden on the consumer. If we leave it like it is here, we'd need to make sure the component doesn't completely break when nothing is provided for rows
, as is happening with DataGrid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought you're right, and after thinking about it the pattern does feel awkward to pass in an empty array.
Done.
isMasked: false, | ||
}; | ||
|
||
function Cell(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So just wanting to make sure, this package will be where all these subcomponents will live instead of in data-grid? So we plan on removing them from data-grid when consuming Table? I have some in-flight changes to both Row and Cell as part of Flowsheet that, depending on the PR review, I would need to make sure don't get lost in the process of migrating these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, yes these components will all live inside this Table package. If you finish first, then I'll be adding your changes into this PR. If I finish first with this then we'll have to make another PR to add in-fight work to this PR when it happens. But most of it should be copy-paste and not require significant rework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard, I'm changing my code to no longer affect Cell or Row.
@@ -36,6 +36,7 @@ | |||
}, | |||
"dependencies": { | |||
"@cerner/terra-docs": "^1.9.0", | |||
"legacy-terra-table": "npm:terra-table@^4.36.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice use of an alias
|
||
## Changes from 4.x to 5.0 | ||
|
||
Terra table will no longer support grid-like (focus, keyboard navigation, etc) functionality and now behaves more like a native, accessible table. See the Docs for new functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be more detailed and list out all the features that are no longer available in 5.0. However, it can be fleshed out in a future doc upgrade Jira and shouldn't prevent merging for now.
packages/terra-table/src/Table.jsx
Outdated
const [cellAriaLiveMessage, setCellAriaLiveMessage] = useState(null); | ||
|
||
const [pinnedColumnOffsets, setPinnedColumnOffsets] = useState([0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these be defined in utils/ColumnContext.jsx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point I'd love to re-factor this and move the code around but like the original table columns logic from datagrid this would be non-trivial to change since AriaLiveMessage is used pretty much everywhere for the screen reader as is the pinned column offsets. We could probably log another JIRA to do this or flesh out the re-factor in another story.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. That's fine then.
/** | ||
* Boolean indicating if cell contents are masked. | ||
*/ | ||
isMasked: PropTypes.bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cell shape still does not have all of its props from the DataGrid package implementation.
* A string identifier used to describe the row contents. This value will be used to construct additional labels | ||
* for internal controls (e.g. row selection cells). | ||
*/ | ||
ariaLabel: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rowShape object does not have all of its props from the DataGrid implementation.
maximumWidth={column.maximumWidth} | ||
headerHeight={headerHeight} | ||
isResizable={column.isResizable} | ||
isSelectable={isGridContext ? column.isSelectable !== false : column.isSelectable} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for column.isSelectable != false is not a present on the current ColumnHeader. With this logic, you are really adding a WorklistDataGrid specific requirement to the Table component. We should probably remove these checks and have WDG pass the appropriate value as Flowsheet does.
key={`${id}_${displayedColumns[cellColumnIndex].id}`} | ||
isSelected={!hasRowSelection && cellData.isSelected} | ||
isMasked={cellData.isMasked} | ||
isSelectable={isGridContext ? cellData.isSelectable !== false : false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a ternary operator here. You could just check
isGridContext && cellData.isSelectable !== false
@@ -0,0 +1,19 @@ | |||
// Source: https://www.npmjs.com/package/element-closest-polyfill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find where this polyfill file is being used? Maybe this file can be removed.
…aria live region to grid context.
|
||
const GridContext = React.createContext({ | ||
role: 'table', | ||
cellAriaLiveMessage: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property should not be required. Nobody is reading the value. The table just needs the ability to call the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return ( | ||
<CellTag | ||
ref={cellRef} | ||
aria-selected={isGridContext ? isSelected : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not have the isGridContext check here. We can just set it based on the selection state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an edge case where aria-selected={false}
in tables creates an accessibility violation, but since since we're saying that cell selection is a grid functionality (which setting the value is allowed) then we can just honor the value from the cell data. Done.
draggable | ||
role="slider" | ||
tabIndex={isGridContext ? -1 : 0} | ||
aria-hidden={isGridContext ? !isActive : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really depend on the grid context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was facing an issue earlier where I was getting accessibility errors, but this works now. Done.
const theme = useContext(ThemeContext); | ||
const columnHeaderCell = useRef(); | ||
|
||
const isGridContext = gridContext.role === GridConstants.GRID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to just made this a function in the GridContext that can be called instead of having to duplicate the logic in multiple files?
There was a problem hiding this comment.
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 React contexts are read-only and we can't reference the values of a context inside itself. So This will have to do for now.
@kenk2 - Great work on Table and the examples! I have a few observations: |
Summary
What was changed:
Implementing new Terra Table. Terra Outline Table is deleted.
Why it was changed:
Implementing new table for datagrid initiatives. Terra Outline Table is obsolete and not being worked on.
Testing
This change was tested using:
Reviews
In addition to engineering reviews, this PR needs:
Additional Details
This PR resolves:
UXPLATFORM-XXXX
Thank you for contributing to Terra.
@cerner/terra