Skip to content

Commit 2d909f5

Browse files
Make resizable require keyboardNavigation
1 parent e12c55b commit 2d909f5

File tree

2 files changed

+22
-42
lines changed

2 files changed

+22
-42
lines changed

components/data-table/__examples__/interactive-elements.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Example extends React.Component {
150150
id="DataTableExample-column-resizable"
151151
fixedLayout
152152
fixedHeader
153-
Resizable
153+
resizable
154154
keyboardNavigation
155155
>
156156
{columns}

components/data-table/__examples__/resizable-columns.jsx

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@ import React from 'react';
33
import DataTable from '~/components/data-table'; // `~` is replaced with design-system-react at runtime
44
import DataTableColumn from '~/components/data-table/column';
55
import DataTableCell from '~/components/data-table/cell';
6+
import DataTableInteractiveLink from '~/components/data-table/interactive-link';
67
import IconSettings from '~/components/icon-settings';
78

8-
const CustomDataTableCell = ({ children, ...props }) => (
9+
const CustomDataTableCellKeyboardNavigation = ({ children, ...props }) => (
910
<DataTableCell {...props}>
10-
<a
11-
href="#"
12-
onClick={(event) => {
13-
event.preventDefault();
14-
}}
15-
>
16-
{children}
17-
</a>
11+
<DataTableInteractiveLink
12+
onClick={(event) => {
13+
event.preventDefault();
14+
}}>
15+
{children}
16+
</DataTableInteractiveLink>
1817
</DataTableCell>
1918
);
20-
CustomDataTableCell.displayName = DataTableCell.displayName;
19+
CustomDataTableCellKeyboardNavigation.displayName = DataTableCell.displayName;
2120

22-
const columns = [
21+
const columnsKeyboardNavigation = [
2322
<DataTableColumn
2423
key="opportunity"
2524
label="Opportunity Name"
2625
property="opportunityName"
2726
>
28-
<CustomDataTableCell />
27+
<CustomDataTableCellKeyboardNavigation />
2928
</DataTableColumn>,
3029

3130
<DataTableColumn
@@ -43,7 +42,7 @@ const columns = [
4342
<DataTableColumn key="amount" label="Amount" property="amount" />,
4443

4544
<DataTableColumn key="contact" label="Contact" property="contact">
46-
<CustomDataTableCell />
45+
<CustomDataTableCellKeyboardNavigation />
4746
</DataTableColumn>,
4847
];
4948

@@ -90,53 +89,33 @@ class Example extends React.Component {
9089
<React.Fragment>
9190
<React.Fragment>
9291
<h3 className="slds-text-heading_medium slds-m-vertical_medium">
93-
Fully resizable
94-
</h3>
95-
<IconSettings iconPath="/assets/icons">
96-
<div style={{ overflow: 'auto' }}>
97-
<DataTable
98-
items={this.state.items}
99-
id="DataTableExample-1-resizable-cols"
100-
resizable
101-
resizerOptions={{
102-
resizeMode: 'overflow',
103-
onResize: (columnsResized) => {
104-
console.log(JSON.stringify(columnsResized));
105-
},
106-
}}
107-
>
108-
{columns}
109-
</DataTable>
110-
</div>
111-
</IconSettings>
112-
</React.Fragment>
113-
<React.Fragment>
114-
<h3 className="slds-text-heading_medium slds-m-vertical_medium">
115-
Columns 0 and 3 fixed
92+
Resizeable: Columns 0 and 3 fixed
11693
</h3>
11794
<IconSettings iconPath="/assets/icons">
11895
<div style={{ overflow: 'auto' }}>
11996
<DataTable
12097
items={this.state.items}
12198
id="DataTableExample-2-resizable-cols"
12299
resizable
100+
fixedHeader
123101
fixedLayout
124-
resizerOptions={{
102+
keyboardNavigation
103+
resizerOptions={{
125104
resizeMode: 'overflow',
126105
onResize: (columnsResized) => {
127106
console.log(JSON.stringify(columnsResized));
128107
},
129108
disabledColumns: [0, 3],
130109
}}
131110
>
132-
{columns}
111+
{columnsKeyboardNavigation}
133112
</DataTable>
134113
</div>
135114
</IconSettings>
136115
</React.Fragment>
137116
<React.Fragment>
138117
<h3 className="slds-text-heading_medium slds-m-vertical_medium">
139-
With fixed header
118+
Resizeable: With fixed header
140119
</h3>
141120
<IconSettings iconPath="/assets/icons">
142121
<div style={{ overflow: 'auto' }}>
@@ -145,6 +124,7 @@ class Example extends React.Component {
145124
id="DataTableExample-3-resizable-cols"
146125
fixedHeader
147126
fixedLayout
127+
keyboardNavigation
148128
resizable
149129
resizerOptions={{
150130
resizeMode: 'overflow',
@@ -153,7 +133,7 @@ class Example extends React.Component {
153133
},
154134
}}
155135
>
156-
{columns}
136+
{columnsKeyboardNavigation}
157137
</DataTable>
158138
</div>
159139
</IconSettings>
@@ -178,7 +158,7 @@ class Example extends React.Component {
178158
},
179159
}}
180160
>
181-
{columns}
161+
{columnsKeyboardNavigation}
182162
</DataTable>
183163
</div>
184164
</IconSettings>

0 commit comments

Comments
 (0)