@patternfly/react-core 4.201.0 → 4.202.0

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 (60) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/Menu/MenuContent.d.ts.map +1 -1
  3. package/dist/esm/components/Menu/MenuContent.js +21 -2
  4. package/dist/esm/components/Menu/MenuContent.js.map +1 -1
  5. package/dist/esm/components/Select/Select.d.ts +5 -3
  6. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  7. package/dist/esm/components/Select/Select.js +36 -17
  8. package/dist/esm/components/Select/Select.js.map +1 -1
  9. package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
  10. package/dist/esm/components/Select/SelectOption.js +3 -3
  11. package/dist/esm/components/Select/SelectOption.js.map +1 -1
  12. package/dist/esm/components/Select/SelectToggle.d.ts +1 -1
  13. package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
  14. package/dist/esm/components/Select/SelectToggle.js +14 -14
  15. package/dist/esm/components/Select/SelectToggle.js.map +1 -1
  16. package/dist/esm/components/Select/selectConstants.d.ts +1 -0
  17. package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
  18. package/dist/esm/components/Select/selectConstants.js.map +1 -1
  19. package/dist/esm/components/TimePicker/TimePicker.d.ts +6 -4
  20. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  21. package/dist/esm/components/TimePicker/TimePicker.js +15 -8
  22. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  23. package/dist/js/components/Menu/MenuContent.d.ts.map +1 -1
  24. package/dist/js/components/Menu/MenuContent.js +21 -2
  25. package/dist/js/components/Menu/MenuContent.js.map +1 -1
  26. package/dist/js/components/Select/Select.d.ts +5 -3
  27. package/dist/js/components/Select/Select.d.ts.map +1 -1
  28. package/dist/js/components/Select/Select.js +36 -17
  29. package/dist/js/components/Select/Select.js.map +1 -1
  30. package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
  31. package/dist/js/components/Select/SelectOption.js +3 -3
  32. package/dist/js/components/Select/SelectOption.js.map +1 -1
  33. package/dist/js/components/Select/SelectToggle.d.ts +1 -1
  34. package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
  35. package/dist/js/components/Select/SelectToggle.js +14 -14
  36. package/dist/js/components/Select/SelectToggle.js.map +1 -1
  37. package/dist/js/components/Select/selectConstants.d.ts +1 -0
  38. package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
  39. package/dist/js/components/Select/selectConstants.js.map +1 -1
  40. package/dist/js/components/TimePicker/TimePicker.d.ts +6 -4
  41. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  42. package/dist/js/components/TimePicker/TimePicker.js +15 -8
  43. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  44. package/dist/umd/react-core.css +31 -2
  45. package/dist/umd/react-core.js +96 -46
  46. package/dist/umd/react-core.min.css +31 -2
  47. package/dist/umd/react-core.min.js +2 -2
  48. package/package.json +6 -6
  49. package/src/components/CodeBlock/examples/CodeBlock.md +2 -195
  50. package/src/components/CodeBlock/examples/CodeBlockBasic.tsx +59 -0
  51. package/src/components/CodeBlock/examples/CodeBlockExpandable.tsx +88 -0
  52. package/src/components/Menu/MenuContent.tsx +27 -2
  53. package/src/components/Select/Select.tsx +39 -18
  54. package/src/components/Select/SelectOption.tsx +7 -4
  55. package/src/components/Select/SelectToggle.tsx +15 -15
  56. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
  57. package/src/components/Select/examples/Select.md +93 -40
  58. package/src/components/Select/selectConstants.tsx +1 -0
  59. package/src/components/TimePicker/TimePicker.tsx +20 -11
  60. package/src/components/TimePicker/examples/TimePicker.md +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.201.0",
3
+ "version": "4.202.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,16 +34,16 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.52.0",
38
- "@patternfly/react-styles": "^4.51.0",
39
- "@patternfly/react-tokens": "^4.53.0",
37
+ "@patternfly/react-icons": "^4.53.0",
38
+ "@patternfly/react-styles": "^4.52.0",
39
+ "@patternfly/react-tokens": "^4.54.0",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
43
43
  "tslib": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@patternfly/patternfly": "4.183.2",
46
+ "@patternfly/patternfly": "4.184.1",
47
47
  "@rollup/plugin-commonjs": "^21.0.0",
48
48
  "@rollup/plugin-node-resolve": "^13.0.0",
49
49
  "@rollup/plugin-replace": "^3.0.0",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "0d60b35858f995deab44e2ede3e013114e495b5e"
63
+ "gitHead": "a328f46967c052f0d72d77dff763ecbb3318bc4e"
64
64
  }
@@ -12,203 +12,10 @@ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
12
12
 
13
13
  ### Basic
14
14
 
15
- ```js
16
- import React from 'react';
17
- import { CodeBlock, CodeBlockAction, CodeBlockCode, ClipboardCopyButton, Button } from '@patternfly/react-core';
18
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
19
- import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
20
-
21
- class BasicCodeBlock extends React.Component {
22
- constructor(props) {
23
- super(props);
24
- this.timer = null;
25
-
26
- this.state = {
27
- copied: false
28
- };
29
-
30
- this.clipboardCopyFunc = (event, text) => {
31
- const clipboard = event.currentTarget.parentElement;
32
- const el = document.createElement('textarea');
33
- el.value = text.toString();
34
- clipboard.appendChild(el);
35
- el.select();
36
- document.execCommand('copy');
37
- clipboard.removeChild(el);
38
- };
39
-
40
- this.onClick = (event, text) => {
41
- if (this.timer) {
42
- window.clearTimeout(this.timer);
43
- this.setState({ copied: false });
44
- }
45
- this.clipboardCopyFunc(event, text);
46
- this.setState({ copied: true }, () => {
47
- this.timer = window.setTimeout(() => {
48
- this.setState({ copied: false });
49
- this.timer = null;
50
- }, 1000);
51
- });
52
- };
53
- }
54
-
55
- render() {
56
- const code = `apiVersion: helm.openshift.io/v1beta1/
57
- kind: HelmChartRepository
58
- metadata:
59
- name: azure-sample-repo
60
- spec:
61
- connectionConfig:
62
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
63
-
64
- const actions = (
65
- <React.Fragment>
66
- <CodeBlockAction>
67
- <ClipboardCopyButton
68
- id="copy-button"
69
- textId="code-content"
70
- aria-label="Copy to clipboard"
71
- onClick={e => this.onClick(e, code)}
72
- exitDelay={600}
73
- maxWidth="110px"
74
- variant="plain"
75
- >
76
- {this.state.copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
77
- </ClipboardCopyButton>
78
- </CodeBlockAction>
79
- <CodeBlockAction>
80
- <Button variant="plain" aria-label="Play icon">
81
- <PlayIcon />
82
- </Button>
83
- </CodeBlockAction>
84
- </React.Fragment>
85
- );
86
-
87
- return (
88
- <CodeBlock actions={actions}>
89
- <CodeBlockCode id="code-content">{code}</CodeBlockCode>
90
- </CodeBlock>
91
- );
92
- }
93
- }
15
+ ```ts file="./CodeBlockBasic.tsx"
94
16
  ```
95
17
 
96
18
  ### Expandable
97
19
 
98
- ```js
99
- import React from 'react';
100
- import {
101
- CodeBlock,
102
- CodeBlockAction,
103
- CodeBlockCode,
104
- ClipboardCopyButton,
105
- ExpandableSection,
106
- ExpandableSectionToggle,
107
- Button
108
- } from '@patternfly/react-core';
109
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
110
- import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
111
-
112
- class BasicCodeBlock extends React.Component {
113
- constructor(props) {
114
- super(props);
115
- this.timer = null;
116
-
117
- this.state = {
118
- isExpanded: false,
119
- copied: false
120
- };
121
-
122
- this.onToggle = isExpanded => {
123
- this.setState({
124
- isExpanded
125
- });
126
- };
127
-
128
- this.clipboardCopyFunc = (event, text) => {
129
- const clipboard = event.currentTarget.parentElement;
130
- const el = document.createElement('textarea');
131
- el.value = text.toString();
132
- clipboard.appendChild(el);
133
- el.select();
134
- document.execCommand('copy');
135
- clipboard.removeChild(el);
136
- };
137
-
138
- this.onClick = (event, text) => {
139
- if (this.timer) {
140
- window.clearTimeout(this.timer);
141
- this.setState({ copied: false });
142
- }
143
- this.clipboardCopyFunc(event, text);
144
- this.setState({ copied: true }, () => {
145
- this.timer = window.setTimeout(() => {
146
- this.setState({ copied: false });
147
- this.timer = null;
148
- }, 1000);
149
- });
150
- };
151
- }
152
-
153
- render() {
154
- const { isExpanded } = this.state;
155
-
156
- const copyBlock = `apiVersion: helm.openshift.io/v1beta1/
157
- kind: HelmChartRepository
158
- metadata:
159
- name: azure-sample-repo
160
- spec:
161
- connectionConfig:
162
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
163
-
164
- const code = `apiVersion: helm.openshift.io/v1beta1/
165
- kind: HelmChartRepository
166
- metadata:
167
- name: azure-sample-repo`;
168
- const expandedCode = `spec:
169
- connectionConfig:
170
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
171
-
172
- const actions = (
173
- <React.Fragment>
174
- <CodeBlockAction>
175
- <ClipboardCopyButton
176
- id="copy-button"
177
- textId="code-content"
178
- aria-label="Copy to clipboard"
179
- onClick={e => this.onClick(e, copyBlock)}
180
- exitDelay={600}
181
- maxWidth="110px"
182
- variant="plain"
183
- >
184
- {this.state.copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
185
- </ClipboardCopyButton>
186
- </CodeBlockAction>
187
- <CodeBlockAction>
188
- <Button variant="plain" aria-label="Play icon">
189
- <PlayIcon />
190
- </Button>
191
- </CodeBlockAction>
192
- </React.Fragment>
193
- );
194
- return (
195
- <CodeBlock actions={actions}>
196
- <CodeBlockCode>
197
- {code}
198
- <ExpandableSection isExpanded={isExpanded} isDetached contentId="code-block-expand">
199
- {expandedCode}
200
- </ExpandableSection>
201
- </CodeBlockCode>
202
- <ExpandableSectionToggle
203
- isExpanded={isExpanded}
204
- onToggle={this.onToggle}
205
- contentId="code-block-expand"
206
- direction="up"
207
- >
208
- {isExpanded ? 'Show Less' : 'Show More'}
209
- </ExpandableSectionToggle>
210
- </CodeBlock>
211
- );
212
- }
213
- }
20
+ ```ts file="./CodeBlockExpandable.tsx"
214
21
  ```
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { CodeBlock, CodeBlockAction, CodeBlockCode, ClipboardCopyButton, Button } from '@patternfly/react-core';
3
+ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
4
+
5
+ export const BasicCodeBlock: React.FunctionComponent = () => {
6
+ const [copied, setCopied] = React.useState(false);
7
+
8
+ const clipboardCopyFunc = (event, text) => {
9
+ const clipboard = event.currentTarget.parentElement;
10
+ const el = document.createElement('textarea');
11
+ el.value = text.toString();
12
+ clipboard.appendChild(el);
13
+ el.select();
14
+ document.execCommand('copy');
15
+ clipboard.removeChild(el);
16
+ };
17
+
18
+ const onClick = (event, text) => {
19
+ clipboardCopyFunc(event, text);
20
+ setCopied(true);
21
+ };
22
+
23
+ const code = `apiVersion: helm.openshift.io/v1beta1/
24
+ kind: HelmChartRepository
25
+ metadata:
26
+ name: azure-sample-repo0oooo00ooo
27
+ spec:
28
+ connectionConfig:
29
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
30
+
31
+ const actions = (
32
+ <React.Fragment>
33
+ <CodeBlockAction>
34
+ <ClipboardCopyButton
35
+ id="copy-button"
36
+ textId="code-content"
37
+ aria-label="Copy to clipboard"
38
+ onClick={e => onClick(e, code)}
39
+ exitDelay={600}
40
+ maxWidth="110px"
41
+ variant="plain"
42
+ >
43
+ {copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
44
+ </ClipboardCopyButton>
45
+ </CodeBlockAction>
46
+ <CodeBlockAction>
47
+ <Button variant="plain" aria-label="Play icon">
48
+ <PlayIcon />
49
+ </Button>
50
+ </CodeBlockAction>
51
+ </React.Fragment>
52
+ );
53
+
54
+ return (
55
+ <CodeBlock actions={actions}>
56
+ <CodeBlockCode id="code-content">{code}</CodeBlockCode>
57
+ </CodeBlock>
58
+ );
59
+ };
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import {
3
+ CodeBlock,
4
+ CodeBlockAction,
5
+ CodeBlockCode,
6
+ ClipboardCopyButton,
7
+ ExpandableSection,
8
+ ExpandableSectionToggle,
9
+ Button
10
+ } from '@patternfly/react-core';
11
+ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
12
+
13
+ export const ExpandableCodeBlock: React.FunctionComponent = () => {
14
+ const [isExpanded, setIsExpanded] = React.useState(false);
15
+ const [copied, setCopied] = React.useState(false);
16
+
17
+ const onToggle = isExpanded => {
18
+ setIsExpanded(isExpanded);
19
+ };
20
+
21
+ const clipboardCopyFunc = (event, text) => {
22
+ const clipboard = event.currentTarget.parentElement;
23
+ const el = document.createElement('textarea');
24
+ el.value = text.toString();
25
+ clipboard.appendChild(el);
26
+ el.select();
27
+ document.execCommand('copy');
28
+ clipboard.removeChild(el);
29
+ };
30
+
31
+ const onClick = (event, text) => {
32
+ clipboardCopyFunc(event, text);
33
+ setCopied(true);
34
+ };
35
+
36
+ const copyBlock = `apiVersion: helm.openshift.io/v1beta1/
37
+ kind: HelmChartRepository
38
+ metadata:
39
+ name: azure-sample-repo
40
+ spec:
41
+ connectionConfig:
42
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
43
+
44
+ const code = `apiVersion: helm.openshift.io/v1beta1/
45
+ kind: HelmChartRepository
46
+ metadata:
47
+ name: azure-sample-repo`;
48
+ const expandedCode = `spec:
49
+ connectionConfig:
50
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
51
+
52
+ const actions = (
53
+ <React.Fragment>
54
+ <CodeBlockAction>
55
+ <ClipboardCopyButton
56
+ id="copy-button"
57
+ textId="code-content"
58
+ aria-label="Copy to clipboard"
59
+ onClick={e => onClick(e, copyBlock)}
60
+ exitDelay={600}
61
+ maxWidth="110px"
62
+ variant="plain"
63
+ >
64
+ {copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
65
+ </ClipboardCopyButton>
66
+ </CodeBlockAction>
67
+ <CodeBlockAction>
68
+ <Button variant="plain" aria-label="Play icon">
69
+ <PlayIcon />
70
+ </Button>
71
+ </CodeBlockAction>
72
+ </React.Fragment>
73
+ );
74
+
75
+ return (
76
+ <CodeBlock actions={actions}>
77
+ <CodeBlockCode>
78
+ {code}
79
+ <ExpandableSection isExpanded={isExpanded} isDetached contentId="code-block-expand">
80
+ {expandedCode}
81
+ </ExpandableSection>
82
+ </CodeBlockCode>
83
+ <ExpandableSectionToggle isExpanded={isExpanded} onToggle={onToggle} contentId="code-block-expand" direction="up">
84
+ {isExpanded ? 'Show Less' : 'Show More'}
85
+ </ExpandableSectionToggle>
86
+ </CodeBlock>
87
+ );
88
+ };
@@ -21,8 +21,33 @@ export const MenuContent = React.forwardRef((props: MenuContentProps, ref: React
21
21
  const menuContentRef = React.createRef<HTMLDivElement>();
22
22
  const refCallback = (el: HTMLElement, menuId: string, onGetMenuHeight: (menuId: string, height: number) => void) => {
23
23
  if (el) {
24
- onGetMenuHeight && onGetMenuHeight(menuId, el.clientHeight);
25
- getHeight && getHeight(el.clientHeight.toString());
24
+ let clientHeight = el.clientHeight;
25
+
26
+ // if this menu is a submenu, we need to account for the root menu list's padding and root menu content's border.
27
+ let rootMenuList = null;
28
+ let parentEl = el.closest(`.${styles.menuList}`);
29
+ while (parentEl !== null && parentEl.nodeType === 1) {
30
+ if (parentEl.classList.contains(styles.menuList)) {
31
+ rootMenuList = parentEl;
32
+ }
33
+ parentEl = parentEl.parentElement;
34
+ }
35
+
36
+ if (rootMenuList) {
37
+ const rootMenuListStyles = getComputedStyle(rootMenuList);
38
+ const rootMenuListPaddingOffset =
39
+ parseFloat(rootMenuListStyles.getPropertyValue('padding-top').replace(/px/g, '')) +
40
+ parseFloat(rootMenuListStyles.getPropertyValue('padding-bottom').replace(/px/g, '')) +
41
+ parseFloat(
42
+ getComputedStyle(rootMenuList.parentElement)
43
+ .getPropertyValue('border-bottom-width')
44
+ .replace(/px/g, '')
45
+ );
46
+ clientHeight = clientHeight + rootMenuListPaddingOffset;
47
+ }
48
+
49
+ onGetMenuHeight && onGetMenuHeight(menuId, clientHeight);
50
+ getHeight && getHeight(clientHeight.toString());
26
51
  }
27
52
  return ref || menuContentRef;
28
53
  };
@@ -122,7 +122,7 @@ export interface SelectProps
122
122
  isPlaceholder?: boolean
123
123
  ) => void;
124
124
  /** Callback for toggle button behavior */
125
- onToggle: (isExpanded: boolean) => void;
125
+ onToggle: (isExpanded: boolean, event: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent | Event) => void;
126
126
  /** Callback for typeahead clear button */
127
127
  onClear?: (event: React.MouseEvent) => void;
128
128
  /** Optional callback for custom filtering */
@@ -159,6 +159,8 @@ export interface SelectProps
159
159
  isInputValuePersisted?: boolean;
160
160
  /** @beta Flag for retaining filter results on blur from keyboard-entered typeahead text */
161
161
  isInputFilterPersisted?: boolean;
162
+ /** Flag indicating the typeahead input value should reset upon selection */
163
+ shouldResetOnSelect?: boolean;
162
164
  /** Content rendered in the footer of the select menu */
163
165
  footer?: React.ReactNode;
164
166
  }
@@ -232,7 +234,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
232
234
  chipGroupComponent: null,
233
235
  isInputValuePersisted: false,
234
236
  isInputFilterPersisted: false,
235
- isCreateSelectOptionObject: false
237
+ isCreateSelectOptionObject: false,
238
+ shouldResetOnSelect: true
236
239
  };
237
240
 
238
241
  state: SelectState = {
@@ -328,7 +331,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
328
331
  this.setState({ focusFirstOption: true });
329
332
  };
330
333
 
331
- onToggle = (isExpanded: boolean) => {
334
+ onToggle = (isExpanded: boolean, e: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent | Event) => {
332
335
  const { isInputValuePersisted, onSelect, onToggle, hasInlineFilter } = this.props;
333
336
  if (!isExpanded && isInputValuePersisted && onSelect) {
334
337
  onSelect(undefined, this.inputRef.current ? this.inputRef.current.value : '');
@@ -338,7 +341,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
338
341
  focusFirstOption: true
339
342
  });
340
343
  }
341
- onToggle(isExpanded);
344
+ onToggle(isExpanded, e);
342
345
  };
343
346
 
344
347
  onClose = () => {
@@ -358,7 +361,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
358
361
 
359
362
  onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
360
363
  if (e.target.value.toString() !== '' && !this.props.isOpen) {
361
- this.onToggle(true);
364
+ this.onToggle(true, e);
362
365
  }
363
366
 
364
367
  if (this.props.onTypeaheadInputChanged) {
@@ -503,9 +506,9 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
503
506
  });
504
507
  };
505
508
 
506
- onClick = (_e: React.MouseEvent) => {
509
+ onClick = (e: React.MouseEvent) => {
507
510
  if (!this.props.isOpen) {
508
- this.onToggle(true);
511
+ this.onToggle(true, e);
509
512
  }
510
513
  };
511
514
 
@@ -678,10 +681,20 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
678
681
  typeaheadCurrIndex !== -1 && // do not allow selection without moving to an initial option
679
682
  (typeaheadActiveChild || (this.refCollection[0] && this.refCollection[0][0]))
680
683
  ) {
681
- this.setState({
682
- typeaheadInputValue:
683
- (typeaheadActiveChild && typeaheadActiveChild.innerText) || this.refCollection[0][0].innerText
684
- });
684
+ if (typeaheadActiveChild) {
685
+ const hasDescriptionElm = typeaheadActiveChild.childElementCount > 1;
686
+ const typeaheadActiveChildText = hasDescriptionElm
687
+ ? (typeaheadActiveChild.firstChild as HTMLElement).innerText
688
+ : typeaheadActiveChild.innerText;
689
+ this.setState({
690
+ typeaheadInputValue: typeaheadActiveChildText
691
+ });
692
+ } else {
693
+ this.setState({
694
+ typeaheadInputValue: this.refCollection[0][0].innerText
695
+ });
696
+ }
697
+
685
698
  if (typeaheadActiveChild) {
686
699
  typeaheadActiveChild.click();
687
700
  } else {
@@ -755,7 +768,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
755
768
  } else {
756
769
  // Close if there is no footer
757
770
  if (!this.props.footer) {
758
- this.onToggle(false);
771
+ this.onToggle(false, null);
759
772
  this.onClose();
760
773
  } else {
761
774
  // has footer
@@ -764,14 +777,14 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
764
777
  if (this.inputRef.current === document.activeElement) {
765
778
  if (shiftKey) {
766
779
  // close toggle if shift key and tab on input
767
- this.onToggle(false);
780
+ this.onToggle(false, null);
768
781
  this.onClose();
769
782
  } else {
770
783
  // tab to first tabbable item in footer
771
784
  if (tabbableItems[0]) {
772
785
  tabbableItems[0].focus();
773
786
  } else {
774
- this.onToggle(false);
787
+ this.onToggle(false, null);
775
788
  this.onClose();
776
789
  }
777
790
  }
@@ -791,7 +804,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
791
804
  tabbableItems[currentElementIndex + 1].focus();
792
805
  } else {
793
806
  // no next item, close toggle
794
- this.onToggle(false);
807
+ this.onToggle(false, null);
795
808
  this.inputRef.current.focus();
796
809
  this.onClose();
797
810
  }
@@ -947,6 +960,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
947
960
  footer,
948
961
  loadingVariant,
949
962
  isCreateSelectOptionObject,
963
+ shouldResetOnSelect,
950
964
  ...props
951
965
  } = this.props;
952
966
  const {
@@ -1085,7 +1099,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1085
1099
  } else if (event.key === KeyTypes.Tab && variant !== SelectVariant.checkbox && this.props.footer) {
1086
1100
  // tab to footer or close menu if shift key
1087
1101
  if (event.shiftKey) {
1088
- this.onToggle(false);
1102
+ this.onToggle(false, event);
1089
1103
  } else {
1090
1104
  const tabbableItems = findTabbableElements(this.footerRef, SelectFooterTabbableItems);
1091
1105
  if (tabbableItems.length > 0) {
@@ -1093,7 +1107,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1093
1107
  event.stopPropagation();
1094
1108
  event.preventDefault();
1095
1109
  } else {
1096
- this.onToggle(false);
1110
+ this.onToggle(false, event);
1097
1111
  }
1098
1112
  }
1099
1113
  } else if (event.key === KeyTypes.Tab && variant === SelectVariant.checkbox) {
@@ -1367,7 +1381,14 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1367
1381
  <GenerateId>
1368
1382
  {randomId => (
1369
1383
  <SelectContext.Provider
1370
- value={{ onSelect, onFavorite, onClose: this.onClose, variant, inputIdPrefix: inputIdPrefix || randomId }}
1384
+ value={{
1385
+ onSelect,
1386
+ onFavorite,
1387
+ onClose: this.onClose,
1388
+ variant,
1389
+ inputIdPrefix: inputIdPrefix || randomId,
1390
+ shouldResetOnSelect
1391
+ }}
1371
1392
  >
1372
1393
  {menuAppendTo === 'inline' ? (
1373
1394
  mainContainer
@@ -245,7 +245,8 @@ export class SelectOption extends React.Component<SelectOptionProps> {
245
245
  onClose: () => void,
246
246
  variant: string,
247
247
  inputIdPrefix: string,
248
- onFavorite: (itemId: string, isFavorite: boolean) => void
248
+ onFavorite: (itemId: string, isFavorite: boolean) => void,
249
+ shouldResetOnSelect: boolean
249
250
  ) => {
250
251
  if (variant !== SelectVariant.checkbox && isLoading && isGrouped) {
251
252
  return (
@@ -323,7 +324,7 @@ export class SelectOption extends React.Component<SelectOptionProps> {
323
324
  if (!isDisabled) {
324
325
  onClick(event);
325
326
  onSelect(event, value, isPlaceholder);
326
- onClose();
327
+ shouldResetOnSelect && onClose();
327
328
  }
328
329
  }}
329
330
  role="option"
@@ -449,8 +450,10 @@ export class SelectOption extends React.Component<SelectOptionProps> {
449
450
 
450
451
  return (
451
452
  <SelectConsumer>
452
- {({ onSelect, onClose, variant, inputIdPrefix, onFavorite }) => (
453
- <React.Fragment>{renderOption(onSelect, onClose, variant, inputIdPrefix, onFavorite)}</React.Fragment>
453
+ {({ onSelect, onClose, variant, inputIdPrefix, onFavorite, shouldResetOnSelect }) => (
454
+ <React.Fragment>
455
+ {renderOption(onSelect, onClose, variant, inputIdPrefix, onFavorite, shouldResetOnSelect)}
456
+ </React.Fragment>
454
457
  )}
455
458
  </SelectConsumer>
456
459
  );