@patternfly/react-table 4.105.1 → 4.105.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "4.105.1",
3
+ "version": "4.105.4",
4
4
  "description": "This library provides a set of React table components for use with the PatternFly 4",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -31,10 +31,10 @@
31
31
  "clean": "rimraf dist"
32
32
  },
33
33
  "dependencies": {
34
- "@patternfly/react-core": "^4.236.1",
35
- "@patternfly/react-icons": "^4.87.1",
36
- "@patternfly/react-styles": "^4.86.1",
37
- "@patternfly/react-tokens": "^4.88.1",
34
+ "@patternfly/react-core": "^4.236.4",
35
+ "@patternfly/react-icons": "^4.87.4",
36
+ "@patternfly/react-styles": "^4.86.4",
37
+ "@patternfly/react-tokens": "^4.88.4",
38
38
  "lodash": "^4.17.19",
39
39
  "tslib": "^2.0.0"
40
40
  },
@@ -46,5 +46,5 @@
46
46
  "react": "^16.8.0 || ^17.0.0",
47
47
  "react-dom": "^16.8.0 || ^17.0.0"
48
48
  },
49
- "gitHead": "1e8f4121716891c90191b948a66eccf167f404ce"
49
+ "gitHead": "c1df72da34f893c6edb6d68d7bf2083bb2d7037c"
50
50
  }
@@ -1,4 +1,4 @@
1
- import { render, screen } from '@testing-library/react';
1
+ import { render, screen, waitFor } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
 
4
4
  import {
@@ -30,7 +30,7 @@ import {
30
30
  ISeparator
31
31
  } from '../TableTypes';
32
32
 
33
- const testCellActions = ({
33
+ const testCellActions = async ({
34
34
  actions,
35
35
  actionResolver,
36
36
  areActionsDisabled,
@@ -45,6 +45,7 @@ const testCellActions = ({
45
45
  extraData?: IExtraData;
46
46
  expectDisabled?: boolean;
47
47
  }) => {
48
+ const user = userEvent.setup();
48
49
  const returnedData = cellActions(
49
50
  actions,
50
51
  actionResolver,
@@ -70,14 +71,16 @@ const testCellActions = ({
70
71
  expect(returnedData.children).toBeUndefined();
71
72
  } else {
72
73
  const { container } = render(returnedData.children as React.ReactElement<any>);
73
- userEvent.click(container.querySelectorAll('.pf-c-dropdown button')[0]);
74
- expect(container.querySelectorAll('.pf-c-dropdown__menu li button')).toHaveLength(expectDisabled ? 0 : 1);
74
+ await user.click(screen.getAllByRole('button')[0]);
75
+ await waitFor(() =>
76
+ expect(container.querySelectorAll('.pf-c-dropdown__menu li button')).toHaveLength(expectDisabled ? 0 : 1)
77
+ );
75
78
  }
76
79
  };
77
80
 
78
81
  describe('Transformer functions', () => {
79
82
  describe('selectable', () => {
80
- test('main select', () => {
83
+ test('main select', async () => {
81
84
  const onSelect = jest.fn((_event, selected, rowId) => ({ selected, rowId }));
82
85
  const column = {
83
86
  extraParams: { onSelect }
@@ -85,24 +88,27 @@ describe('Transformer functions', () => {
85
88
  const returnedData = selectable('', { column, rowData: {} } as IExtra);
86
89
  expect(returnedData).toMatchObject({ className: 'pf-c-table__check' });
87
90
 
91
+ const user = userEvent.setup();
92
+
88
93
  render(returnedData.children as React.ReactElement<any>);
89
94
 
90
- userEvent.type(screen.getByRole('textbox'), 'a');
95
+ await user.type(screen.getByRole('textbox'), 'a');
91
96
  expect(onSelect).toHaveBeenCalledTimes(1);
92
97
  expect(onSelect.mock.results[0].value).toMatchObject({ rowId: -1, selected: false });
93
98
  });
94
99
 
95
- test('selected', () => {
100
+ test('selected', async () => {
96
101
  const onSelect = jest.fn((_event, selected, rowId) => ({ selected, rowId }));
97
102
  const column = {
98
103
  extraParams: { onSelect }
99
104
  };
100
105
  const returnedData = selectable('', { column, rowIndex: 0, rowData: { selected: true } } as IExtra);
101
106
  expect(returnedData).toMatchObject({ className: 'pf-c-table__check' });
107
+ const user = userEvent.setup();
102
108
 
103
109
  render(returnedData.children as React.ReactElement<any>);
104
110
 
105
- userEvent.type(screen.getByRole('textbox'), 'a');
111
+ await user.type(screen.getByRole('textbox'), 'a');
106
112
  expect(onSelect).toHaveBeenCalledTimes(1);
107
113
  expect(onSelect.mock.results[0].value).toMatchObject({ rowId: 0, selected: false });
108
114
  });
@@ -118,41 +124,47 @@ describe('Transformer functions', () => {
118
124
  });
119
125
 
120
126
  describe('sortable', () => {
121
- test('unsorted', () => {
127
+ test('unsorted', async () => {
122
128
  const onSort = jest.fn();
123
129
  const column = { extraParams: { sortBy: {}, onSort } };
124
130
  const returnedData = sortable('', { column, columnIndex: 0 });
125
131
  expect(returnedData).toMatchObject({ className: 'pf-c-table__sort' });
126
132
 
133
+ const user = userEvent.setup();
134
+
127
135
  render(returnedData.children as React.ReactElement<any>);
128
- userEvent.click(screen.getByRole('button'));
136
+ await user.click(screen.getByRole('button'));
129
137
  expect(onSort.mock.calls).toHaveLength(1);
130
138
  });
131
139
 
132
- test('asc', () => {
140
+ test('asc', async () => {
133
141
  const onSort = jest.fn();
134
142
  const column = { extraParams: { sortBy: { index: 0, direction: 'asc' }, onSort } };
135
143
  const returnedData = sortable('', { column, columnIndex: 0 } as IExtra);
136
144
  expect(returnedData).toMatchSnapshot();
137
145
 
146
+ const user = userEvent.setup();
147
+
138
148
  render(returnedData.children as React.ReactElement<any>);
139
- userEvent.click(screen.getByRole('button'));
149
+ await user.click(screen.getByRole('button'));
140
150
  expect(onSort.mock.calls).toHaveLength(1);
141
151
  });
142
152
 
143
- test('desc', () => {
153
+ test('desc', async () => {
144
154
  const onSort = jest.fn();
145
155
  const column = { extraParams: { sortBy: { index: 0, direction: 'desc' }, onSort } };
146
156
  const returnedData = sortable('', { column, columnIndex: 0 } as IExtra);
147
157
  expect(returnedData).toMatchObject({ className: 'pf-c-table__sort pf-m-selected' });
148
158
 
159
+ const user = userEvent.setup();
160
+
149
161
  render(returnedData.children as React.ReactElement<any>);
150
- userEvent.click(screen.getByRole('button'));
162
+ await user.click(screen.getByRole('button'));
151
163
  expect(onSort.mock.calls).toHaveLength(1);
152
164
  });
153
165
  });
154
166
 
155
- test('simpleCellActions', () => {
167
+ test('simpleCellActions', async () => {
156
168
  const actions: IActions = [
157
169
  {
158
170
  title: 'Some',
@@ -205,7 +217,7 @@ describe('Transformer functions', () => {
205
217
  );
206
218
  });
207
219
 
208
- test('collapsible', () => {
220
+ test('collapsible', async () => {
209
221
  const onCollapse = jest.fn();
210
222
  const rowData = {
211
223
  isOpen: true
@@ -216,8 +228,10 @@ describe('Transformer functions', () => {
216
228
  const returnedData = collapsible('', { rowIndex: 0, rowData, column });
217
229
  expect(returnedData).toMatchObject({ className: 'pf-c-table__toggle' });
218
230
 
231
+ const user = userEvent.setup();
232
+
219
233
  render(returnedData.children as React.ReactElement<any>);
220
- userEvent.click(screen.getByRole('button'));
234
+ await user.click(screen.getByRole('button'));
221
235
  expect(onCollapse.mock.calls).toHaveLength(1);
222
236
  });
223
237
 
@@ -315,6 +315,8 @@ To make a row draggable:
315
315
 
316
316
  ## Sticky table modifiers
317
317
 
318
+ To make certain columns and the header sticky, the table must be wrapped in a combination of `OuterScrollContainer` and `InnerScrollContainer`. For sticky columns, only `InnerScrollContainer` is required. For sticky headers, and sticky headers with sticky columns, both containers are required to ensure the sticky behavior behaves correctly.
319
+
318
320
  **Note:** Sticky table headers and columns have a higher `z-index` than the `z-index` used for menus (dropdown, select, etc). The intent is that the contents of a scrollable table will scroll under the sticky header/column, including any expanded menus. However, there may be use cases where a menu needs to appear on top of a sticky header/column, such as an expanded menu in a toolbar above a table with a sticky header.
319
321
 
320
322
  There are a few ways this can be handled:
@@ -339,7 +341,7 @@ To make multiple columns sticky, wrap `TableComposable` with `InnerScrollContain
339
341
 
340
342
  ### Composable: Sticky columns and header
341
343
 
342
- To maintain proper sticky behavior across sticky columns and header, `TableComposable` must be wrapped with `OuterScrollContainer` and `InnerScrollContainer` as shown in the example below.
344
+ To maintain proper sticky behavior across sticky columns and header, `TableComposable` must be wrapped with `OuterScrollContainer` and `InnerScrollContainer`.
343
345
 
344
346
  ```ts file="ComposableTableStickyColumnsAndHeader.tsx"
345
347
  ```