@patternfly/react-table 6.0.0-prerelease.14 → 6.0.0-prerelease.16

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/package.json +1 -1
  3. package/deprecated/package.json +1 -1
  4. package/dist/dynamic/components/Table/package.json +1 -1
  5. package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
  6. package/dist/dynamic/components/Table/utils/package.json +1 -1
  7. package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
  8. package/dist/dynamic/deprecated/components/Table/package.json +1 -1
  9. package/dist/dynamic/deprecated/components/package.json +1 -1
  10. package/dist/esm/components/Table/EditableSelectInputCell.d.ts +2 -0
  11. package/dist/esm/components/Table/EditableSelectInputCell.d.ts.map +1 -1
  12. package/dist/esm/components/Table/EditableSelectInputCell.js +4 -6
  13. package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
  14. package/dist/esm/components/Table/SortColumn.d.ts +2 -0
  15. package/dist/esm/components/Table/SortColumn.d.ts.map +1 -1
  16. package/dist/esm/components/Table/SortColumn.js +11 -1
  17. package/dist/esm/components/Table/SortColumn.js.map +1 -1
  18. package/dist/esm/components/Table/TableTypes.d.ts +1 -0
  19. package/dist/esm/components/Table/TableTypes.d.ts.map +1 -1
  20. package/dist/esm/components/Table/Th.d.ts.map +1 -1
  21. package/dist/esm/components/Table/Th.js +9 -4
  22. package/dist/esm/components/Table/Th.js.map +1 -1
  23. package/dist/esm/components/Table/base/types.d.ts +9 -3
  24. package/dist/esm/components/Table/base/types.d.ts.map +1 -1
  25. package/dist/esm/components/Table/base/types.js.map +1 -1
  26. package/dist/esm/components/Table/utils/decorators/sortable.d.ts.map +1 -1
  27. package/dist/esm/components/Table/utils/decorators/sortable.js +20 -16
  28. package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
  29. package/dist/esm/components/Table/utils/headerUtils.d.ts +7 -0
  30. package/dist/esm/components/Table/utils/headerUtils.d.ts.map +1 -1
  31. package/dist/js/components/Table/EditableSelectInputCell.d.ts +2 -0
  32. package/dist/js/components/Table/EditableSelectInputCell.d.ts.map +1 -1
  33. package/dist/js/components/Table/EditableSelectInputCell.js +4 -6
  34. package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
  35. package/dist/js/components/Table/SortColumn.d.ts +2 -0
  36. package/dist/js/components/Table/SortColumn.d.ts.map +1 -1
  37. package/dist/js/components/Table/SortColumn.js +11 -1
  38. package/dist/js/components/Table/SortColumn.js.map +1 -1
  39. package/dist/js/components/Table/TableTypes.d.ts +1 -0
  40. package/dist/js/components/Table/TableTypes.d.ts.map +1 -1
  41. package/dist/js/components/Table/Th.d.ts.map +1 -1
  42. package/dist/js/components/Table/Th.js +9 -4
  43. package/dist/js/components/Table/Th.js.map +1 -1
  44. package/dist/js/components/Table/base/types.d.ts +9 -3
  45. package/dist/js/components/Table/base/types.d.ts.map +1 -1
  46. package/dist/js/components/Table/base/types.js.map +1 -1
  47. package/dist/js/components/Table/utils/decorators/sortable.d.ts.map +1 -1
  48. package/dist/js/components/Table/utils/decorators/sortable.js +20 -16
  49. package/dist/js/components/Table/utils/decorators/sortable.js.map +1 -1
  50. package/dist/js/components/Table/utils/headerUtils.d.ts +7 -0
  51. package/dist/js/components/Table/utils/headerUtils.d.ts.map +1 -1
  52. package/dist/umd/assets/{output-B1hwgPcG.css → output-D2TqAB3r.css} +10478 -10331
  53. package/dist/umd/react-table.min.js +2 -2
  54. package/package.json +3 -3
  55. package/src/components/Table/EditableSelectInputCell.tsx +7 -8
  56. package/src/components/Table/SortColumn.tsx +28 -0
  57. package/src/components/Table/TableTypes.tsx +1 -0
  58. package/src/components/Table/Th.tsx +10 -3
  59. package/src/components/Table/base/types.tsx +10 -3
  60. package/src/components/Table/examples/Table.md +1 -1
  61. package/src/components/Table/examples/TableFavoritable.tsx +30 -5
  62. package/src/components/Table/utils/decorators/sortable.tsx +6 -4
  63. package/src/deprecated/components/Table/examples/Table.md +36 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "6.0.0-prerelease.14",
3
+ "version": "6.0.0-prerelease.16",
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",
@@ -40,7 +40,7 @@
40
40
  "subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
41
41
  },
42
42
  "dependencies": {
43
- "@patternfly/react-core": "^6.0.0-prerelease.14",
43
+ "@patternfly/react-core": "^6.0.0-prerelease.15",
44
44
  "@patternfly/react-icons": "^6.0.0-prerelease.4",
45
45
  "@patternfly/react-styles": "^6.0.0-prerelease.3",
46
46
  "@patternfly/react-tokens": "^6.0.0-prerelease.4",
@@ -51,5 +51,5 @@
51
51
  "react": "^17 || ^18",
52
52
  "react-dom": "^17 || ^18"
53
53
  },
54
- "gitHead": "9a679a4df32c7246c085c895acb3c4ab1c28472f"
54
+ "gitHead": "d29e2351921da25429652d253e22eec26dc64ddf"
55
55
  }
@@ -25,6 +25,8 @@ export interface IEditableSelectInputCell extends Omit<React.HTMLProps<HTMLEleme
25
25
  options?: React.ReactElement[];
26
26
  /** Flag indicating the select input is disabled */
27
27
  isDisabled?: boolean;
28
+ /** Flag indicating the toggle gets placeholder styles **/
29
+ isPlaceholder?: boolean;
28
30
  /** Current selected options to display as the read only value of the table cell */
29
31
  selections?: any | any[];
30
32
  /** Flag indicating the select menu is open */
@@ -42,17 +44,14 @@ export const EditableSelectInputCell: React.FunctionComponent<IEditableSelectInp
42
44
  onSelect = () => {},
43
45
  clearSelection,
44
46
  isOpen = false,
47
+ isPlaceholder = false,
45
48
  onToggle = () => {},
46
49
  selections = [''],
47
50
  options = [] as React.ReactElement[],
48
51
  props
49
52
  }: IEditableSelectInputCell) => {
50
- const onSelectHandler = (
51
- event: React.MouseEvent | React.ChangeEvent,
52
- newValue: any | any[]
53
- // isPlaceholder: boolean
54
- ) => {
55
- onSelect(event, newValue, rowIndex, cellIndex);
53
+ const onSelectHandler = (event: React.MouseEvent | React.ChangeEvent, newValue: any | any[]) => {
54
+ onSelect(event, newValue, rowIndex, cellIndex, isPlaceholder);
56
55
  };
57
56
 
58
57
  const onClear = (event: React.MouseEvent) => {
@@ -61,16 +60,16 @@ export const EditableSelectInputCell: React.FunctionComponent<IEditableSelectInp
61
60
 
62
61
  const select = (
63
62
  <Select
64
- {...props.editableSelectProps}
65
63
  onSelect={onSelectHandler}
66
64
  {...(clearSelection && { onClear })}
67
65
  isOpen={isOpen}
68
66
  selected={selections}
69
67
  toggle={(toggleRef: any) => (
70
- <MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen}>
68
+ <MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen} isPlaceholder={isPlaceholder}>
71
69
  {isOpen ? 'Expanded' : 'Collapsed'}
72
70
  </MenuToggle>
73
71
  )}
72
+ {...props.editableSelectProps}
74
73
  >
75
74
  <SelectList>{options}</SelectList>
76
75
  </Select>
@@ -2,10 +2,13 @@ import * as React from 'react';
2
2
  import LongArrowAltUpIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-up-icon';
3
3
  import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
4
4
  import ArrowsAltVIcon from '@patternfly/react-icons/dist/esm/icons/arrows-alt-v-icon';
5
+ import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
5
6
  import { css } from '@patternfly/react-styles';
6
7
  import styles from '@patternfly/react-styles/css/components/Table/table';
7
8
  import { TableText } from './TableText';
8
9
  import { TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
10
+ import { ActionList, ActionListItem, Button } from '@patternfly/react-core';
11
+ import { FavoriteButtonProps } from './base/types';
9
12
 
10
13
  export enum SortByDirection {
11
14
  asc = 'asc',
@@ -21,6 +24,7 @@ export interface SortColumnProps extends React.ButtonHTMLAttributes<HTMLButtonEl
21
24
  tooltip?: React.ReactNode;
22
25
  tooltipProps?: Omit<TooltipProps, 'content'>;
23
26
  tooltipHasDefaultBehavior?: boolean;
27
+ favoriteButtonProps?: FavoriteButtonProps;
24
28
  }
25
29
 
26
30
  export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
@@ -33,6 +37,7 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
33
37
  tooltip,
34
38
  tooltipProps,
35
39
  tooltipHasDefaultBehavior,
40
+ favoriteButtonProps,
36
41
  ...props
37
42
  }: SortColumnProps) => {
38
43
  let SortedByIcon;
@@ -42,6 +47,29 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
42
47
  } else {
43
48
  SortedByIcon = ArrowsAltVIcon;
44
49
  }
50
+
51
+ if (favoriteButtonProps) {
52
+ return (
53
+ <ActionList isIconList>
54
+ <ActionListItem>
55
+ <Button variant="plain" icon={<StarIcon />} {...favoriteButtonProps} />
56
+ </ActionListItem>
57
+ <ActionListItem>
58
+ <Button
59
+ variant="plain"
60
+ icon={
61
+ <span className={css(styles.tableSortIndicator)}>
62
+ <SortedByIcon />
63
+ </span>
64
+ }
65
+ onClick={(event) => onSort && onSort(event)}
66
+ {...props}
67
+ />
68
+ </ActionListItem>
69
+ </ActionList>
70
+ );
71
+ }
72
+
45
73
  return (
46
74
  <button
47
75
  {...props}
@@ -109,6 +109,7 @@ export interface IColumn {
109
109
  allRowsExpanded?: boolean;
110
110
  isHeaderSelectDisabled?: boolean;
111
111
  onFavorite?: OnFavorite;
112
+ favoriteButtonProps?: ButtonProps;
112
113
  };
113
114
  }
114
115
 
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import styles from '@patternfly/react-styles/css/components/Table/table';
4
4
  import scrollStyles from '@patternfly/react-styles/css/components/Table/table-scrollable';
5
+ import accessibilityStyles from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
5
6
  import { info, sortable, sortableFavorites, selectable, collapsible, cellWidth, Visibility, classNames } from './utils';
6
7
  import { ThInfoType, ThSelectType, ThExpandType, ThSortType, formatterValueType } from './base/types';
7
8
  import { mergeProps } from './base/merge-props';
@@ -113,15 +114,18 @@ const ThBase: React.FunctionComponent<ThProps> = ({
113
114
  }
114
115
  onMouseEnterProp(event);
115
116
  };
117
+
116
118
  let sortParams = null;
117
119
  if (sort) {
118
120
  if (sort.isFavorites) {
119
121
  sortParams = sortableFavorites({
120
- onSort: sort?.onSort,
122
+ onSort: sort.onSort,
121
123
  columnIndex: sort.columnIndex,
122
124
  sortBy: sort.sortBy,
123
125
  tooltip: tooltip as string,
124
- tooltipProps
126
+ tooltipProps,
127
+ ariaLabel: sort['aria-label'],
128
+ favoriteButtonProps: sort.favoriteButtonProps
125
129
  })();
126
130
  } else {
127
131
  sortParams = sortable(children as IFormatterValueType, {
@@ -137,6 +141,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
137
141
  });
138
142
  }
139
143
  }
144
+
140
145
  const selectParams = select
141
146
  ? selectable(children as IFormatterValueType, {
142
147
  rowData: {
@@ -217,6 +222,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
217
222
  hasRightBorder && scrollStyles.modifiers.borderRight,
218
223
  hasLeftBorder && scrollStyles.modifiers.borderLeft,
219
224
  modifier && styles.modifiers[modifier as 'breakWord' | 'fitContent' | 'nowrap' | 'truncate' | 'wrap'],
225
+ sort?.favoriteButtonProps?.favorited && styles.modifiers.favorited,
220
226
  mergedClassName
221
227
  )}
222
228
  {...mergedProps}
@@ -230,7 +236,8 @@ const ThBase: React.FunctionComponent<ThProps> = ({
230
236
  } as React.CSSProperties
231
237
  })}
232
238
  >
233
- {transformedChildren || (screenReaderText && <span className="pf-v5-screen-reader">{screenReaderText}</span>)}
239
+ {transformedChildren ||
240
+ (screenReaderText && <span className={accessibilityStyles.screenReader}>{screenReaderText}</span>)}
234
241
  </MergedComponent>
235
242
  );
236
243
 
@@ -6,9 +6,7 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import { TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
10
- import { PopoverProps } from '@patternfly/react-core/dist/esm/components/Popover';
11
- import { SelectProps } from '@patternfly/react-core/dist/esm/components/Select';
9
+ import { ButtonProps, PopoverProps, SelectProps, TooltipProps } from '@patternfly/react-core';
12
10
  import { Table } from '../Table';
13
11
  import { Thead } from '../Thead';
14
12
  import { Tbody } from '../Tbody';
@@ -156,6 +154,11 @@ export interface ThInfoType {
156
154
  className?: string;
157
155
  }
158
156
 
157
+ export interface FavoriteButtonProps extends ButtonProps {
158
+ /** Flag if the button is favorited. */
159
+ favorited?: boolean;
160
+ }
161
+
159
162
  export interface ThSortType {
160
163
  /** Wraps the content in a button and adds a sort icon - Click callback on the sortable cell */
161
164
  onSort?: OnSort;
@@ -163,8 +166,12 @@ export interface ThSortType {
163
166
  sortBy: ISortBy;
164
167
  /** The column index */
165
168
  columnIndex: number;
169
+ /** Adds accessible text to the sort button. */
170
+ 'aria-label'?: string;
166
171
  /** True to make this a favoritable sorting cell */
167
172
  isFavorites?: boolean;
173
+ /** Props for the favorite button (only for favoritable cell). */
174
+ favoriteButtonProps?: FavoriteButtonProps;
168
175
  }
169
176
 
170
177
  export interface ThSelectType {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  id: Table
3
- cssPrefix: pf-c-table
3
+ cssPrefix: pf-v6-c-table
4
4
  section: components
5
5
  propComponents:
6
6
  [
@@ -28,10 +28,10 @@ export const TableFavoritable: React.FunctionComponent = () => {
28
28
  // Index of the currently sorted column
29
29
  // Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
30
30
  // as the identifier of the sorted column. See the "Compound expandable" example.
31
- const [activeSortIndex, setActiveSortIndex] = React.useState<number | null>(null);
31
+ const [activeSortIndex, setActiveSortIndex] = React.useState<number>();
32
32
 
33
33
  // Sort direction of the currently sorted column
34
- const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc' | null>(null);
34
+ const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc'>();
35
35
 
36
36
  // Favorite state is similar to selection state, see Selectable with checkbox.
37
37
  const [favoriteRepoNames, setFavoriteRepoNames] = React.useState<string[]>([]);
@@ -42,6 +42,9 @@ export const TableFavoritable: React.FunctionComponent = () => {
42
42
  });
43
43
  const isRepoFavorited = (repo: Repository) => favoriteRepoNames.includes(repo.name);
44
44
 
45
+ // State of the header cell to favorite / unfavorite all rows
46
+ const [headerFavorited, setHeaderFavorited] = React.useState(false);
47
+
45
48
  // Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
46
49
  // In this example we only deal with booleans here because we only sort on the favorites column.
47
50
  // For more complex sorting, see Sortable.
@@ -55,7 +58,7 @@ export const TableFavoritable: React.FunctionComponent = () => {
55
58
  // Note that we perform the sort as part of the component's render logic and not in onSort.
56
59
  // We shouldn't store the list of data in state because we don't want to have to sync that with props.
57
60
  let sortedRepositories = repositories;
58
- if (activeSortIndex !== null) {
61
+ if (activeSortIndex !== undefined) {
59
62
  sortedRepositories = repositories.sort((a, b) => {
60
63
  const aValue = getSortableRowValues(a)[activeSortIndex];
61
64
  const bValue = getSortableRowValues(b)[activeSortIndex];
@@ -80,7 +83,16 @@ export const TableFavoritable: React.FunctionComponent = () => {
80
83
  setActiveSortIndex(index);
81
84
  setActiveSortDirection(direction);
82
85
  },
83
- columnIndex
86
+ 'aria-label': 'Sort favorites',
87
+ columnIndex,
88
+ favoriteButtonProps: {
89
+ favorited: headerFavorited,
90
+ onClick: (_event) => {
91
+ repositories.forEach((repo) => setRepoFavorited(repo, !headerFavorited));
92
+ setHeaderFavorited(!headerFavorited);
93
+ },
94
+ 'aria-label': headerFavorited ? 'Unfavorite all' : 'Favorite all'
95
+ }
84
96
  });
85
97
 
86
98
  return (
@@ -101,7 +113,20 @@ export const TableFavoritable: React.FunctionComponent = () => {
101
113
  <Td
102
114
  favorites={{
103
115
  isFavorited: isRepoFavorited(repo),
104
- onFavorite: (_event, isFavoriting) => setRepoFavorited(repo, isFavoriting),
116
+ onFavorite: (_event, isFavoriting) => {
117
+ setRepoFavorited(repo, isFavoriting);
118
+
119
+ if (
120
+ isFavoriting &&
121
+ repositories.filter((r) => r !== repo).every((r) => favoriteRepoNames.includes(r.name))
122
+ ) {
123
+ setHeaderFavorited(true);
124
+ }
125
+
126
+ if (!isFavoriting && favoriteRepoNames.length === 1 && favoriteRepoNames.includes(repo.name)) {
127
+ setHeaderFavorited(false);
128
+ }
129
+ },
105
130
  rowIndex
106
131
  }}
107
132
  />
@@ -8,12 +8,13 @@ import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
8
8
  export const sortableFavorites = (sort: any) => () =>
9
9
  sortable(<StarIcon aria-hidden />, {
10
10
  columnIndex: sort.columnIndex,
11
- className: styles.modifiers.favorite,
12
- ariaLabel: 'Sort favorites',
11
+ className: styles.tableFavorite,
12
+ ariaLabel: sort.ariaLabel ?? 'Sort favorites',
13
13
  column: {
14
14
  extraParams: {
15
15
  sortBy: sort.sortBy,
16
- onSort: sort?.onSort
16
+ onSort: sort.onSort,
17
+ favoriteButtonProps: sort.favoriteButtonProps
17
18
  }
18
19
  },
19
20
  tooltip: sort.tooltip,
@@ -26,7 +27,7 @@ export const sortable: ITransform = (
26
27
  { columnIndex, column, property, className, ariaLabel, tooltip, tooltipProps, tooltipHasDefaultBehavior }: IExtra
27
28
  ) => {
28
29
  const {
29
- extraParams: { sortBy, onSort }
30
+ extraParams: { sortBy, onSort, favoriteButtonProps }
30
31
  } = column;
31
32
 
32
33
  const extraData = {
@@ -62,6 +63,7 @@ export const sortable: ITransform = (
62
63
  tooltip={tooltip}
63
64
  tooltipProps={tooltipProps}
64
65
  tooltipHasDefaultBehavior={tooltipHasDefaultBehavior}
66
+ favoriteButtonProps={favoriteButtonProps}
65
67
  >
66
68
  {label as React.ReactNode}
67
69
  </SortColumn>
@@ -325,9 +325,10 @@ import {
325
325
  applyCellEdits,
326
326
  EditableTextCell,
327
327
  EditableSelectInputCell,
328
- SelectOption
329
328
  } from '@patternfly/react-table';
330
329
 
330
+ import { SelectOption as NewSelectOption} from '@patternfly/react-core/dist/esm/components/Select';
331
+
331
332
  class EditableRowsTable extends React.Component {
332
333
  constructor(props) {
333
334
  super(props);
@@ -412,12 +413,12 @@ class EditableRowsTable extends React.Component {
412
413
  onSelect={this.onSelect}
413
414
  isOpen={props.isSelectOpen}
414
415
  options={props.options.map((option, index) => (
415
- <SelectOption key={index} value={option.value} id={'uniqueIdRow1Cell4Option' + index}>
416
+ <NewSelectOption key={index} value={option.value} id={'uniqueIdRow1Cell4Option' + index}>
416
417
  {option.value}
417
- </SelectOption>
418
+ </NewSelectOption>
418
419
  ))}
419
- onToggle={(event, isOpen) => {
420
- this.onToggle(isOpen, rowIndex, cellIndex);
420
+ onToggle={(event) => {
421
+ this.onToggle(props.isSelectOpen, rowIndex, cellIndex);
421
422
  }}
422
423
  selections={props.selected}
423
424
  />
@@ -435,8 +436,8 @@ class EditableRowsTable extends React.Component {
435
436
  { value: 'Option 5' }
436
437
  ],
437
438
  editableSelectProps: {
438
- variant: 'single',
439
- 'aria-label': 'Row 1 cell 4 content'
439
+ 'aria-label': 'Row 1 cell 4 content',
440
+ onOpenChange: (isOpen: boolean) => this.onOpenChange(isOpen, 0, 3)
440
441
  }
441
442
  }
442
443
  }
@@ -505,13 +506,13 @@ class EditableRowsTable extends React.Component {
505
506
  isOpen={props.isSelectOpen}
506
507
  options={props.options.map((option, index) => {
507
508
  return (
508
- <SelectOption key={index} value={option.value} id={'uniqueIdRow2Cell4Option' + index}>
509
+ <NewSelectOption key={index} value={option.value} id={'uniqueIdRow2Cell4Option' + index}>
509
510
  {option.value}
510
- </SelectOption>
511
+ </NewSelectOption>
511
512
  );
512
513
  })}
513
- onToggle={(event, isOpen) => {
514
- this.onToggle(isOpen, rowIndex, cellIndex);
514
+ onToggle={(event) => {
515
+ this.onToggle(props.isSelectOpen, rowIndex, cellIndex);
515
516
  }}
516
517
  selections={props.selected}
517
518
  />
@@ -521,8 +522,9 @@ class EditableRowsTable extends React.Component {
521
522
  name: 'uniqueIdRow2Cell4',
522
523
  isSelectOpen: props.isSelectOpen || false,
523
524
  selected: props.selected || [],
525
+ isPlaceholder: true,
524
526
  options: [
525
- { value: 'Placeholder...', isPlaceholder: true },
527
+ { value: 'Placeholder...', isPlaceholder: true},
526
528
  { value: 'Option 1' },
527
529
  { value: 'Option 2' },
528
530
  { value: 'Option 3' },
@@ -530,9 +532,10 @@ class EditableRowsTable extends React.Component {
530
532
  { value: 'Option 5' }
531
533
  ],
532
534
  editableSelectProps: {
533
- variant: 'typeaheadmulti',
534
535
  'aria-label': 'Row 2 cell 4 content',
535
- toggleId: 'editable-toggle'
536
+ toggleId: 'editable-toggle',
537
+ onOpenChange: (isOpen: boolean) => this.onOpenChange(isOpen, 1, 3)
538
+
536
539
  }
537
540
  }
538
541
  }
@@ -622,12 +625,12 @@ class EditableRowsTable extends React.Component {
622
625
  clearSelection={this.clearSelection}
623
626
  isOpen={props.isSelectOpen}
624
627
  options={props.options.map((option, index) => (
625
- <SelectOption key={index} value={option.value} id={'uniqueIdRow3Cell4Option' + index}>
628
+ <NewSelectOption key={index} value={option.value} id={'uniqueIdRow3Cell4Option' + index}>
626
629
  {option.value}
627
- </SelectOption>
630
+ </NewSelectOption>
628
631
  ))}
629
- onToggle={(event, isOpen) => {
630
- this.onToggle(isOpen, rowIndex, cellIndex);
632
+ onToggle={(event) => {
633
+ this.onToggle(props.isSelectOpen, rowIndex, cellIndex);
631
634
  }}
632
635
  selections={props.selected}
633
636
  />
@@ -637,8 +640,9 @@ class EditableRowsTable extends React.Component {
637
640
  name: 'uniqueIdRow3Cell4',
638
641
  isSelectOpen: props.isSelectOpen || false,
639
642
  selected: props.selected || ['Option 3'],
643
+ isPlaceholder: false,
640
644
  options: [
641
- { value: 'Placeholder...', isPlaceholder: true },
645
+ { value: 'Placeholder...', isPlaceholder: true},
642
646
  { value: 'Option 1' },
643
647
  { value: 'Option 2' },
644
648
  { value: 'Option 3' },
@@ -646,8 +650,9 @@ class EditableRowsTable extends React.Component {
646
650
  { value: 'Option 5' }
647
651
  ],
648
652
  editableSelectProps: {
649
- variant: 'checkbox',
650
- 'aria-label': 'Row 3 cell 4 content'
653
+ 'aria-label': 'Row 3 cell 4 content',
654
+ onOpenChange: (isOpen: boolean) => this.onOpenChange(isOpen, 2, 3)
655
+
651
656
  }
652
657
  }
653
658
  }
@@ -735,10 +740,19 @@ class EditableRowsTable extends React.Component {
735
740
  });
736
741
  };
737
742
 
743
+ // set open state if component closes menu on click (e.g. when you click outside of the menu)
744
+ this.onOpenChange = (isOpen: boolean, rowIndex: string | number | undefined, cellIndex: string | number | undefined) => {
745
+ const newRows = Array.from(this.state.rows);
746
+ newRows[rowIndex].cells[cellIndex].props.isSelectOpen = isOpen;
747
+ this.setState({
748
+ rows: newRows
749
+ });
750
+ }
751
+
738
752
  this.onToggle = (isOpen, rowIndex, cellIndex) => {
739
753
  console.log('isOpen', isOpen);
740
754
  let newRows = Array.from(this.state.rows);
741
- newRows[rowIndex].cells[cellIndex].props.isSelectOpen = isOpen;
755
+ newRows[rowIndex].cells[cellIndex].props.isSelectOpen = !newRows[rowIndex].cells[cellIndex].props.isSelectOpen;
742
756
  this.setState({
743
757
  rows: newRows
744
758
  });