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

[worklist-data-grid] column enhancements #1859

Merged
merged 152 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
4586b1b
Copy src from branch UXPLATFORM-9147
sycombs Sep 25, 2023
61e616e
Copy docs/tests from UXPLATFORM-9147 branch
sycombs Sep 25, 2023
41d5697
Copy changelog entry
sycombs Sep 25, 2023
f0c547b
Copy the Jest updates
sycombs Sep 25, 2023
d0e71e5
Add translations
sycombs Sep 25, 2023
f83a0d8
Merge remote-tracking branch 'origin/main' into wdg_column_resizing
sycombs Sep 25, 2023
d2c2959
role 'slider' changed to be null when slider is not active
adoroshk Sep 29, 2023
0cc9d6e
Merge branch 'main' into wdg_column_resizing
adoroshk Sep 29, 2023
6356750
aria-label and aria-valuetext adjusted, role reverted
adoroshk Sep 29, 2023
c64ad23
slider - divider interchangable roles
adoroshk Oct 2, 2023
0dad843
use isNavigationEnabled for role
adoroshk Oct 2, 2023
5568179
testing without aria-valuetext, aria-label only
adoroshk Oct 2, 2023
b727ebe
combined aria-label
adoroshk Oct 2, 2023
2a4ceeb
aria-label and aria-valuetext adjusted
adoroshk Oct 2, 2023
ff48e99
added cell-focus-trapped and resume-navigation texts
adoroshk Oct 2, 2023
1b15e28
enabling navigation after setting column header aria live message
adoroshk Oct 2, 2023
78b23ed
removed columnWidthAnnouncement from aria-label
adoroshk Oct 3, 2023
a4fd285
Merge branch 'main' into wdg_column_resizing
adoroshk Oct 3, 2023
835c69d
state variables for aria-label and aria-valuetext added
adoroshk Oct 3, 2023
bc74a4a
ariaLabel and ariaValueText switched to boolean
adoroshk Oct 3, 2023
e2d3d3b
aria-label assigned on focus and removed on Enter or onBlur
adoroshk Oct 3, 2023
4de9bae
revert table prop changes
sdadn Oct 5, 2023
c949b32
updated ColumnResizeHandle.scss
sdadn Oct 5, 2023
82615a0
removed tableheight
sdadn Oct 6, 2023
526698c
removed table height calculation
sdadn Oct 6, 2023
04a321e
reverted condition
sdadn Oct 6, 2023
010c3f9
revert colors
sdadn Oct 6, 2023
ca10df4
Removed space
sdadn Oct 6, 2023
9569340
linter fixes
sdadn Oct 6, 2023
52c788e
linter fixes
sdadn Oct 6, 2023
ce7f8ea
Merge branch 'main' into wdg_column_resizing
sdadn Oct 6, 2023
fb573e5
added column resize handle tests
sdadn Oct 9, 2023
bc4901e
column header cell updates
sdadn Oct 9, 2023
a3320ed
linter fixes
sdadn Oct 9, 2023
db90402
updated column header cell snapshots
sdadn Oct 11, 2023
d5c6ea0
updated snapshots
sdadn Oct 11, 2023
256a9f5
fix for role slider or no role at all
adoroshk Oct 11, 2023
e1b6ddf
Merge branch 'main' into wdg_column_resizing
adoroshk Oct 11, 2023
b28d215
added wdio tests
sdadn Oct 13, 2023
7f5cf5d
merged main into current branch
sdadn Oct 13, 2023
c4b58f1
fixed jest tests
sdadn Oct 13, 2023
955a02e
linter fixes
sdadn Oct 13, 2023
698d130
updated datagrid test
sdadn Oct 13, 2023
b634939
Merge branch 'main' into wdg_column_resizing
sdadn Oct 13, 2023
48a60cc
Apply suggestions from code review
sdadn Oct 16, 2023
e4be9b6
Update packages/terra-data-grid/src/subcomponents/ColumnResizeHandle.jsx
sdadn Oct 16, 2023
84f17e0
Changed to focus button in the column header
Oct 16, 2023
30e3985
Update for github actions. Will be reverted later
Oct 16, 2023
e5fd211
Merge branch 'main' into wdg_column_resizing
sdadn Oct 17, 2023
6e66593
updated datagrid
sdadn Oct 17, 2023
281cf72
Updated selector for tests
Oct 18, 2023
74fb315
fixed isResizeHandleActive not resetting
sdadn Oct 18, 2023
5868be5
working column resizing
sdadn Oct 18, 2023
cb29ed1
updated tests
sdadn Oct 19, 2023
58ba111
working tests
sdadn Oct 20, 2023
aac35bf
linter fixes
sdadn Oct 20, 2023
9340a4c
removed polyfill
sdadn Oct 20, 2023
b81bf75
updated snapshots
sdadn Oct 20, 2023
0fc61be
updated snapshots
sdadn Oct 20, 2023
7cd98b5
updated snapshots
sdadn Oct 20, 2023
f74b948
updated CHANGELOG
sdadn Oct 20, 2023
00353ed
linter fixes
sdadn Oct 20, 2023
670288f
Merge branch 'main' into wdg_column_resizing
sdadn Oct 20, 2023
e149d55
updates wdio snapshots
sdadn Oct 20, 2023
88581fc
Merge branch 'wdg_column_resizing' into UXPLATFORM-9611
Oct 23, 2023
59f0e41
Copy src from branch UXPLATFORM-9147
sycombs Sep 25, 2023
a1e6335
Copy docs/tests from UXPLATFORM-9147 branch
sycombs Sep 25, 2023
fb99fa6
Copy changelog entry
sycombs Sep 25, 2023
8aa89e7
Copy the Jest updates
sycombs Sep 25, 2023
d6a7426
Add translations
sycombs Sep 25, 2023
95dfd27
role 'slider' changed to be null when slider is not active
adoroshk Sep 29, 2023
92ca8e2
aria-label and aria-valuetext adjusted, role reverted
adoroshk Sep 29, 2023
1132fe4
slider - divider interchangable roles
adoroshk Oct 2, 2023
68d8f7c
use isNavigationEnabled for role
adoroshk Oct 2, 2023
97c35b5
testing without aria-valuetext, aria-label only
adoroshk Oct 2, 2023
fca1293
combined aria-label
adoroshk Oct 2, 2023
f0bd6d6
aria-label and aria-valuetext adjusted
adoroshk Oct 2, 2023
a138504
added cell-focus-trapped and resume-navigation texts
adoroshk Oct 2, 2023
c91ede8
enabling navigation after setting column header aria live message
adoroshk Oct 2, 2023
22ba7ae
removed columnWidthAnnouncement from aria-label
adoroshk Oct 3, 2023
5e0add7
state variables for aria-label and aria-valuetext added
adoroshk Oct 3, 2023
7ed7b02
ariaLabel and ariaValueText switched to boolean
adoroshk Oct 3, 2023
b6e34d3
aria-label assigned on focus and removed on Enter or onBlur
adoroshk Oct 3, 2023
c30b5c7
revert table prop changes
sdadn Oct 5, 2023
56cd5dc
updated ColumnResizeHandle.scss
sdadn Oct 5, 2023
ecbcfae
removed tableheight
sdadn Oct 6, 2023
6d0e943
removed table height calculation
sdadn Oct 6, 2023
18eb9d3
reverted condition
sdadn Oct 6, 2023
cd85988
revert colors
sdadn Oct 6, 2023
a3132dc
Removed space
sdadn Oct 6, 2023
1b35ff5
linter fixes
sdadn Oct 6, 2023
a90be14
linter fixes
sdadn Oct 6, 2023
1d23137
added column resize handle tests
sdadn Oct 9, 2023
5b99b1d
column header cell updates
sdadn Oct 9, 2023
261aa7e
linter fixes
sdadn Oct 9, 2023
34b1df6
updated column header cell snapshots
sdadn Oct 11, 2023
21ef483
updated snapshots
sdadn Oct 11, 2023
e3fb719
fix for role slider or no role at all
adoroshk Oct 11, 2023
bc963f2
added wdio tests
sdadn Oct 13, 2023
180f1e0
fixed jest tests
sdadn Oct 13, 2023
af6c0f3
linter fixes
sdadn Oct 13, 2023
afe7792
updated datagrid test
sdadn Oct 13, 2023
0881406
Apply suggestions from code review
sdadn Oct 16, 2023
e1f5aed
Update packages/terra-data-grid/src/subcomponents/ColumnResizeHandle.jsx
sdadn Oct 16, 2023
b0121ce
updated datagrid
sdadn Oct 17, 2023
17b65c8
fixed isResizeHandleActive not resetting
sdadn Oct 18, 2023
d8e8a08
working column resizing
sdadn Oct 18, 2023
2dfb130
updated tests
sdadn Oct 19, 2023
10d12e6
working tests
sdadn Oct 20, 2023
d86aad4
linter fixes
sdadn Oct 20, 2023
bf1a082
removed polyfill
sdadn Oct 20, 2023
054c35b
updated snapshots
sdadn Oct 20, 2023
658b79b
updated snapshots
sdadn Oct 20, 2023
0dd9dda
updated snapshots
sdadn Oct 20, 2023
4949114
updated CHANGELOG
sdadn Oct 20, 2023
fbb0ed4
linter fixes
sdadn Oct 20, 2023
1214313
updates wdio snapshots
sdadn Oct 20, 2023
a4d7f99
updated styles
sdadn Oct 23, 2023
fb409b2
fixed tests
sdadn Oct 23, 2023
a2e12e1
Changes to focus button for column header cell
Oct 23, 2023
96e9da9
Merge branch 'wdg_column_resizing' into UXPLATFORM-9611
Oct 23, 2023
7de1a76
Added tests and fixed console, build errors
Oct 23, 2023
21fcb04
linter fixes
sdadn Oct 23, 2023
092d86b
trigger build
sdadn Oct 23, 2023
c40d11a
temp style change
sdadn Oct 23, 2023
3500205
refined code & updated styles
sdadn Oct 23, 2023
e277f94
linter fixes
sdadn Oct 24, 2023
5fec855
updated wdio snapshots
sdadn Oct 24, 2023
f63e48e
added translations
sdadn Oct 24, 2023
0a74744
Merge branch 'wdg_column_resizing' into UXPLATFORM-9611
Oct 24, 2023
4fa2502
Updated WDIO screenshots for new resize handle styles
Oct 24, 2023
016ab65
Added Changelog for documentation update.
Oct 24, 2023
54fbe17
Merge branch 'main' into wdg_column_resizing
sdadn Oct 24, 2023
c179d0e
updated wdio snapshots
sdadn Oct 24, 2023
af90d0c
updated wdio snapshots
sdadn Oct 24, 2023
b00d53f
reverted null to undefined
sdadn Oct 24, 2023
9cb7c6d
added tests
sdadn Oct 24, 2023
a026f67
updated variable
sdadn Oct 24, 2023
3abc115
updated variable name
sdadn Oct 24, 2023
21a4ceb
updated snapshot
sdadn Oct 24, 2023
ad6ad83
Merge branch 'wdg_column_resizing' into UXPLATFORM-9611
brithom Oct 24, 2023
15bc0e1
fix snapshop
brithom Oct 24, 2023
46c86b0
updated scss name
sdadn Oct 24, 2023
2a068f7
updated snapshots
sdadn Oct 24, 2023
fe7af39
Merge branch 'wdg_column_resizing' into UXPLATFORM-9611
brithom Oct 24, 2023
8809618
[terra-worklist-data-grid] added keyboard support for column resizing…
sdadn Oct 25, 2023
5fbd942
Update ci-cd.yml
sdadn Oct 25, 2023
dc3d7be
Update pr-preview.yml
sdadn Oct 25, 2023
a520e2e
Update CHANGELOG.md
sdadn Oct 25, 2023
f46f2d4
Update CHANGELOG.md
sdadn Oct 25, 2023
380b0ce
Update CHANGELOG.md
sdadn Oct 25, 2023
24866de
updated snapshots
sdadn Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/terra-data-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Changelog

## Unreleased

* Added
* Added additional screen reader support to announce that column headers are interactable upon selection.
* Added keyboard support for column resizing.
* Added translations.
* Added "No Result" cells to FlowsheetDataGrid.

## 0.8.1 - (October 17, 2023)
Expand Down Expand Up @@ -42,7 +44,7 @@
* Updated the `terra-worklist-data-grid` component to set initial focus to the row selection header when row selection mode is enabled.

___
All release notes below apply to the `terra-worklist-data-grid` package (renamed to `terra-data-grid` the 0.6 release above).
All release notes below apply to the `terra-worklist-data-grid` package (renamed to `terra-data-grid` with the 0.6 release above).

## 0.5.0 - (August 31, 2023)

Expand Down
61 changes: 57 additions & 4 deletions packages/terra-data-grid/src/DataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ const propTypes = {
*/
columnHeaderHeight: PropTypes.string,

/**
* Numeric increment in pixels to adjust column width when resizing via the keyboard.
*/
columnResizeIncrement: PropTypes.number,

/**
* String that specifies the height for the rows in the grid. Any valid CSS value is accepted.
*/
Expand Down Expand Up @@ -136,6 +141,7 @@ const DataGrid = injectIntl((props) => {
onColumnResize,
defaultColumnWidth,
columnHeaderHeight,
columnResizeIncrement,
rowHeight,
onColumnSelect,
onCellSelect,
Expand Down Expand Up @@ -174,18 +180,23 @@ const DataGrid = injectIntl((props) => {
const activeColumnWidth = useRef(200);
const tableWidth = useRef(0);

// Reference variable for WorklistDataGrid table element
const grid = useRef();
const gridContainerRef = useRef();

const handleFocus = useRef(true);

const [checkResizable, setCheckResizable] = useState(false);
const [focusedRow, setFocusedRow] = useState(0);
const [focusedCol, setFocusedCol] = useState(0);
const [gridHasFocus, setGridHasFocus] = useState(false);

// Aria live region message management
const [columnHeaderAriaLiveMessage, setColumnHeaderAriaLiveMessage] = useState(null);
const [cellAriaLiveMessage, setCellAriaLiveMessage] = useState(null);

// Define ColumnContext Provider value object
const columnContextValue = useMemo(() => ({ pinnedColumnOffsets, setCellAriaLiveMessage }), [pinnedColumnOffsets]);

const columnContextValue = useMemo(() => ({ pinnedColumnOffsets, setColumnHeaderAriaLiveMessage, setCellAriaLiveMessage }), [pinnedColumnOffsets]);
const theme = useContext(ThemeContext);

// -------------------------------------
Expand Down Expand Up @@ -323,11 +334,12 @@ const DataGrid = injectIntl((props) => {
setFocusedRowCol(toCell.row, toCell.col, true);
};

const handleColumnSelect = useCallback((columnId, cellCoordinates) => {
const handleColumnSelect = useCallback((columnId, cellCoordinates, isSelectable) => {
setFocusedRow(cellCoordinates.row);
setFocusedCol(cellCoordinates.col);

if (onColumnSelect) {
// Notify consumers of column header selection
if (isSelectable && onColumnSelect) {
onColumnSelect(columnId);
}
}, [onColumnSelect]);
Expand Down Expand Up @@ -401,10 +413,12 @@ const DataGrid = injectIntl((props) => {
const cellCoordinates = { row: focusedRow, col: focusedCol };
let nextRow = cellCoordinates.row;
let nextCol = cellCoordinates.col;
setCheckResizable(false);

const targetElement = event.target;

// Allow default behavior if the event target is an editable field

if (event.keyCode !== KeyCode.KEY_TAB
&& (isTextInput(targetElement)
|| ['textarea', 'select'].indexOf(targetElement.tagName.toLowerCase()) >= 0
Expand Down Expand Up @@ -434,6 +448,7 @@ const DataGrid = injectIntl((props) => {
} else {
// Left key
nextCol -= 1;
setCheckResizable(cellCoordinates.row === 0);
}
break;
case KeyCode.KEY_RIGHT:
Expand Down Expand Up @@ -502,10 +517,31 @@ const DataGrid = injectIntl((props) => {
activeColumnPageX.current = event.pageX;
activeColumnWidth.current = resizeColumnWidth;

setFocusedRow(0);
setFocusedCol(index);

// Set the active index to the selected column
setActiveIndex(index);
}, []);

const onResizeHandleChange = useCallback((columnIndex, increment) => {
const { minimumWidth, maximumWidth, width } = dataGridColumns[columnIndex];
const newColumnWidth = Math.min(Math.max(width + increment, minimumWidth), maximumWidth);

// Update the width for the column in the state variable
const newGridColumns = [...dataGridColumns];
newGridColumns[columnIndex].width = newColumnWidth;
setDataGridColumns(newGridColumns);

// Update the column and table width
grid.current.style.width = `${grid.current.offsetWidth + increment}px`;

// Notify consumers of the new column width
if (onColumnResize) {
onColumnResize(dataGridColumns[columnIndex].id, dataGridColumns[columnIndex].width);
}
}, [dataGridColumns, onColumnResize]);

const onMouseMove = (event) => {
if (activeIndex == null) {
return;
Expand Down Expand Up @@ -540,17 +576,28 @@ const DataGrid = injectIntl((props) => {
handleFocus.current = false;
};

/**
* Establishes selection state when the WorklistDataGrid gains focus
* @param {*} event focus event data
*/
const onFocus = (event) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
// Not triggered when swapping focus between children
if (handleFocus.current) {
setFocusedRowCol(focusedRow, focusedCol, true);
setGridHasFocus(true);
}
}

handleFocus.current = true;
};

const onBlur = (event) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
setGridHasFocus(false);
}
};

// -------------------------------------

return (
Expand All @@ -564,6 +611,7 @@ const DataGrid = injectIntl((props) => {
className={cx('data-grid', theme.className)}
onKeyDown={handleKeyDown}
onFocus={onFocus}
onBlur={onBlur}
onMouseDown={onMouseDown}
tabIndex={0}
{...(activeIndex != null && { onMouseUp, onMouseMove, onMouseLeave: onMouseUp })}
Expand All @@ -575,8 +623,12 @@ const DataGrid = injectIntl((props) => {
columns={dataGridColumns}
headerHeight={columnHeaderHeight}
tableHeight={tableHeight}
activeColumnIndex={(gridHasFocus && focusedRow === 0) ? focusedCol : undefined}
isActiveColumnResizing={focusedRow === 0 && checkResizable}
columnResizeIncrement={columnResizeIncrement}
onColumnSelect={handleColumnSelect}
onResizeMouseDown={onResizeMouseDown}
onResizeHandleChange={onResizeHandleChange}
/>
<tbody>
{rows.map((row, index) => (
Expand All @@ -597,6 +649,7 @@ const DataGrid = injectIntl((props) => {
</tbody>
</ColumnContext.Provider>
</table>
<VisuallyHiddenText aria-live="polite" aria-atomic="true" text={columnHeaderAriaLiveMessage} />
<VisuallyHiddenText aria-live="polite" aria-atomic="true" text={cellAriaLiveMessage} />
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/terra-data-grid/src/DataGrid.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Style for the grid itself
border-collapse: separate;
border-spacing: 0;
// Allow for resizing of last grid column
margin-right: 15px;
table-layout: fixed;
user-select: none;
width: 1px;
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-data-grid/src/WorklistDataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function WorklistDataGrid(props) {
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
className={cx('worklist-data-grid-container')}
onFocus={!gridReceivedFocus.current && onFocus}
onFocus={!gridReceivedFocus.current ? onFocus : undefined}
>
<DataGrid
id={id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:local {
.clinical-lowlight-theme {
// Column resize handle styles
--terra-data-grid-resize-handle-focus-border-color: rgba(34, 42, 46, 1);
--terra-data-grid-resize-handle-active-border-color: rgba(34, 42, 46, 1);
--terra-data-grid-resize-handle-hover-border-color: rgba(34, 42, 46, 0.6);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:local {
.orion-fusion-theme {
// Column resize handle styles
--terra-data-grid-resize-handle-focus-border-color: #517ea5;
--terra-data-grid-resize-handle-active-border-color: #517ea5;
--terra-data-grid-resize-handle-hover-border-color: #e4f1f7;
}
}
31 changes: 26 additions & 5 deletions packages/terra-data-grid/src/subcomponents/ColumnHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,48 @@ const propTypes = {
* String that specifies the column header height. Any valid CSS height value accepted.
*/
headerHeight: PropTypes.string.isRequired,

/**
* Number that specifies the height of the data grid in pixels.
*/
* Number that specifies the height of the data grid in pixels.
*/
tableHeight: PropTypes.number,

/**
* Column index for cell that can receive tab focus.
*/
activeColumnIndex: PropTypes.number,
/**
* Specifies if resize handle should be active.
*/
isActiveColumnResizing: PropTypes.bool,
/**
* Numeric increment in pixels to adjust column width when resizing via the keyboard.
*/
columnResizeIncrement: PropTypes.number,
/**
* Function that is called when a selectable header cell is selected. Parameters:
* @param {string} columnId columnId
*/
onColumnSelect: PropTypes.func,

/**
* Function that is called when the mouse down event is triggered on the column resize handle.
*/
onResizeMouseDown: PropTypes.func,
/**
* Function that is called when the the keyboard is used to adjust the column size.
*/
onResizeHandleChange: PropTypes.func,
};

const ColumnHeader = (props) => {
const {
columns,
headerHeight,
tableHeight,
activeColumnIndex,
isActiveColumnResizing,
columnResizeIncrement,
onColumnSelect,
onResizeMouseDown,
onResizeHandleChange,
} = props;

// Create ColumnHeaderCell component for each column
Expand All @@ -56,10 +73,14 @@ const ColumnHeader = (props) => {
isResizable={column.isResizable}
isSelectable={column.isSelectable}
tableHeight={tableHeight}
isActive={activeColumnIndex === columnIndex}
isResizeActive={activeColumnIndex === columnIndex && isActiveColumnResizing}
columnResizeIncrement={columnResizeIncrement}
hasError={column.hasError}
sortIndicator={column.sortIndicator}
onColumnSelect={onColumnSelect}
onResizeMouseDown={onResizeMouseDown}
onResizeHandleChange={onResizeHandleChange}
/>
);

Expand Down
Loading
Loading