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

[flowsheet-data-grid] Hide columns headers #1882

Merged
merged 36 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7f3164d
updated flowsheet datagrid to no longer have columns
sdadn Nov 8, 2023
dd531ac
updated screenshots
sdadn Nov 8, 2023
2000abd
updated snapshots
sdadn Nov 8, 2023
ed71e7a
updated props
sdadn Nov 8, 2023
2695239
updated implementation & examples
sdadn Nov 8, 2023
2ff6581
updated undefined error
sdadn Nov 8, 2023
7c82eca
updated jest snapshots
sdadn Nov 8, 2023
5d50a10
updated wdio screenshots
sdadn Nov 8, 2023
f619dc4
added examples
sdadn Nov 8, 2023
c7705b1
updated CHANGELOGs
sdadn Nov 9, 2023
6bb658a
updated screenshots
sdadn Nov 9, 2023
9a95bbd
linter fixes
sdadn Nov 9, 2023
6bf4017
fixed examples
sdadn Nov 9, 2023
4e96fbb
updated example
sdadn Nov 9, 2023
e314504
updated prop
sdadn Nov 13, 2023
b95e1ac
updated CHANGELOG
sdadn Nov 13, 2023
5f405b3
updated prop
sdadn Nov 13, 2023
3dfb79b
updated datagrid to not allow navigation to hidden header columns
sdadn Nov 14, 2023
69e447c
Merge branch 'main' into hide-flowsheet-column-header
sdadn Nov 14, 2023
a29f395
wdio tests wip
sdadn Nov 14, 2023
d528416
Merge branch 'hide-flowsheet-column-header' of github.com:cerner/terr…
sdadn Nov 14, 2023
523a90b
working wdio tests
sdadn Nov 14, 2023
0d47e8f
updated jest snapshots
sdadn Nov 14, 2023
95fcf31
removed only from tests
sdadn Nov 14, 2023
e616978
finished renaming prop
sdadn Nov 14, 2023
eeb124d
updated docs
sdadn Nov 14, 2023
8dbbd5a
linter fixes
sdadn Nov 14, 2023
33d3ebf
updated wdio tests
sdadn Nov 14, 2023
2606bcd
Update CHANGELOG.md
sdadn Nov 15, 2023
a561ac9
Update CHANGELOG.md
sdadn Nov 15, 2023
766fbf5
updated keyboard navigation logic
sdadn Nov 15, 2023
5808984
Merge branch 'main' into hide-flowsheet-column-header
sdadn Nov 15, 2023
3e03f99
Merge branch 'hide-flowsheet-column-header' of github.com:cerner/terr…
sdadn Nov 15, 2023
a69cf68
Update CHANGELOG.md
sdadn Nov 15, 2023
f38c857
Merge branch 'main' into hide-flowsheet-column-header
sdadn Nov 15, 2023
9fe8502
updated jest snapshots
sdadn Nov 15, 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
3 changes: 3 additions & 0 deletions packages/terra-data-grid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Fixed
* Fixed issue where focus was given to the column header instead of its button element.

* Added
* Added `hasVisibleColumnHeaders` prop for FlowsheetDataGrid to toggle visibility of column headers.

## 1.1.0 - (November 9, 2023)

Expand Down
36 changes: 23 additions & 13 deletions packages/terra-data-grid/src/DataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ const propTypes = {
* rendered to allow for row selection to occur.
*/
hasSelectableRows: PropTypes.bool,

/**
* Boolean indicating whether or not the DataGrid should hide the column headers.
*/
hasVisibleColumnHeaders: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -136,29 +141,31 @@ const defaultProps = {
pinnedColumns: [],
overflowColumns: [],
rows: [],
hasVisibleColumnHeaders: true,
};

const DataGrid = injectIntl((props) => {
const {
id,
ariaLabelledBy,
ariaLabel,
rows,
pinnedColumns,
overflowColumns,
onColumnResize,
defaultColumnWidth,
ariaLabelledBy,
columnHeaderHeight,
columnResizeIncrement,
rowHeight,
onColumnSelect,
defaultColumnWidth,
hasVisibleColumnHeaders,
hasSelectableRows,
id,
onCellRangeSelect,
onCellSelect,
onClearSelection,
onColumnResize,
onColumnSelect,
onRangeSelection,
onRowSelectionHeaderSelect,
onCellRangeSelect,
hasSelectableRows,
overflowColumns,
pinnedColumns,
rowHeaderIndex,
rowHeight,
rows,
} = props;

const displayedColumns = (hasSelectableRows ? [WorklistDataGridUtils.ROW_SELECTION_COLUMN] : []).concat(pinnedColumns).concat(overflowColumns);
Expand All @@ -179,7 +186,9 @@ const DataGrid = injectIntl((props) => {
const handleFocus = useRef(true);

const [checkResizable, setCheckResizable] = useState(false);
const [focusedRow, setFocusedRow] = useState(0);

// if columns are not visible then set the first selectable row index to 1
const [focusedRow, setFocusedRow] = useState(hasVisibleColumnHeaders ? 0 : 1);
const [focusedCol, setFocusedCol] = useState(0);
const [gridHasFocus, setGridHasFocus] = useState(false);

Expand Down Expand Up @@ -455,7 +464,7 @@ const DataGrid = injectIntl((props) => {
event.preventDefault(); // prevent the page from moving with the arrow keys.
return;
}
if (nextCol < 0 || nextRow < 0) {
if (nextCol < 0 || nextRow < (hasVisibleColumnHeaders ? 0 : 1)) {
event.preventDefault(); // prevent the page from moving with the arrow keys.
return;
}
Expand Down Expand Up @@ -525,6 +534,7 @@ const DataGrid = injectIntl((props) => {
onCellSelect={handleCellSelection}
onRowSelectionHeaderSelect={handleRowSelectionHeaderSelect}
hasSelectableRows={hasSelectableRows}
hasVisibleColumnHeaders={hasVisibleColumnHeaders}
isStriped
/>
</GridContext.Provider>
Expand Down
8 changes: 8 additions & 0 deletions packages/terra-data-grid/src/FlowsheetDataGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ const propTypes = {
* The intl object containing translations. This is retrieved from the context automatically by injectIntl.
*/
intl: PropTypes.shape({ formatMessage: PropTypes.func }).isRequired,

/**
* Boolean to show/hide column headers. By default, it is set to `true` and column headers are visible.
*/
hasVisibleColumnHeaders: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -90,6 +95,7 @@ const defaultProps = {
rowHeight: '2.5rem',
rows: [],
columns: [],
hasVisibleColumnHeaders: true,
};

function FlowsheetDataGrid(props) {
Expand All @@ -106,6 +112,7 @@ function FlowsheetDataGrid(props) {
onClearSelectedCells,
onCellRangeSelect,
intl,
hasVisibleColumnHeaders,
} = props;

const anchorCell = useRef(null);
Expand Down Expand Up @@ -295,6 +302,7 @@ function FlowsheetDataGrid(props) {
onCellSelect={handleCellSelection}
onClearSelection={handleClearSelectedCells}
onCellRangeSelect={handleCellRangeSelection}
hasVisibleColumnHeaders={hasVisibleColumnHeaders}
/>
<VisuallyHiddenText aria-live="polite" text={cellSelectionAriaLiveMessage} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -320,6 +321,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -488,6 +490,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
<InjectIntl(Table)
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
isActiveColumnResizing={false}
isStriped={true}
Expand Down Expand Up @@ -602,7 +605,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
<Table
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
intl={
Object {
Expand Down Expand Up @@ -808,7 +811,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
},
]
}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
headerHeight="2.5rem"
isActiveColumnResizing={false}
onColumnSelect={[Function]}
Expand All @@ -819,7 +822,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
>
<thead>
<tr
aria-rowindex={1}
className="column-header-row"
height="2.5rem"
>
Expand Down Expand Up @@ -3081,6 +3083,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -3241,6 +3244,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -3409,6 +3413,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
<InjectIntl(Table)
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
isActiveColumnResizing={false}
isStriped={true}
Expand Down Expand Up @@ -3523,7 +3528,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
<Table
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
intl={
Object {
Expand Down Expand Up @@ -3729,7 +3734,7 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
},
]
}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
headerHeight="2.5rem"
isActiveColumnResizing={false}
onColumnSelect={[Function]}
Expand All @@ -3740,7 +3745,6 @@ exports[`DataGrid verifies onCellSelect callback is triggered when space is pres
>
<thead>
<tr
aria-rowindex={1}
className="column-header-row"
height="2.5rem"
>
Expand Down Expand Up @@ -5994,6 +5998,7 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
defaultColumnWidth={200}
focusFuncRef={null}
hasSelectableRows={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -6145,6 +6150,7 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
defaultColumnWidth={200}
focusFuncRef={null}
hasSelectableRows={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -6304,6 +6310,7 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasSelectableRows={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
isActiveColumnResizing={false}
isStriped={true}
Expand Down Expand Up @@ -6418,8 +6425,8 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
<Table
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasColumnHeaders={true}
hasSelectableRows={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
intl={
Object {
Expand Down Expand Up @@ -6641,7 +6648,7 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
},
]
}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
headerHeight="2.5rem"
isActiveColumnResizing={false}
onColumnSelect={[Function]}
Expand All @@ -6652,7 +6659,6 @@ exports[`DataGrid verifies row selection column header selection 1`] = `
>
<thead>
<tr
aria-rowindex={1}
className="column-header-row"
height="2.5rem"
>
Expand Down Expand Up @@ -9620,6 +9626,7 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -9757,6 +9764,7 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -9902,6 +9910,7 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
<InjectIntl(Table)
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
isActiveColumnResizing={false}
isStriped={true}
Expand Down Expand Up @@ -10016,7 +10025,7 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
<Table
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
intl={
Object {
Expand Down Expand Up @@ -10222,7 +10231,7 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
},
]
}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
headerHeight="2.5rem"
isActiveColumnResizing={false}
onColumnSelect={[Function]}
Expand All @@ -10233,7 +10242,6 @@ exports[`DataGrid verifies that the grid created is consistent with the rows and
>
<thead>
<tr
aria-rowindex={1}
className="column-header-row"
height="2.5rem"
>
Expand Down Expand Up @@ -12468,6 +12476,7 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -12602,6 +12611,7 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
focusFuncRef={null}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid"
intl={
Object {
Expand Down Expand Up @@ -12744,6 +12754,7 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
<InjectIntl(Table)
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
isActiveColumnResizing={false}
isStriped={true}
Expand Down Expand Up @@ -12855,7 +12866,7 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
<Table
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
id="test-terra-data-grid-table"
intl={
Object {
Expand Down Expand Up @@ -13058,7 +13069,7 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
},
]
}
hasColumnHeaders={true}
hasVisibleColumnHeaders={true}
headerHeight="2.5rem"
isActiveColumnResizing={false}
onColumnSelect={[Function]}
Expand All @@ -13069,7 +13080,6 @@ exports[`DataGrid verifies the rows are created with the right props 1`] = `
>
<thead>
<tr
aria-rowindex={1}
className="column-header-row"
height="2.5rem"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`FlowsheetDataGrid renders the row header column as pinned and remaining
ariaLabel="Test Flowsheet Data Grid"
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-flowsheet-data-grid"
onCellRangeSelect={[Function]}
onCellSelect={[Function]}
Expand Down Expand Up @@ -130,6 +131,7 @@ exports[`FlowsheetDataGrid replaces non-header empty, null, or "--" cell content
ariaLabel="Test Flowsheet Data Grid"
columnHeaderHeight="2.5rem"
defaultColumnWidth={200}
hasVisibleColumnHeaders={true}
id="test-terra-flowsheet-data-grid"
onCellRangeSelect={[Function]}
onCellSelect={[Function]}
Expand Down
Loading
Loading