@patternfly/react-core 4.192.7 → 4.192.11

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 (100) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/esm/components/Label/Label.d.ts.map +1 -1
  3. package/dist/esm/components/Label/Label.js +38 -25
  4. package/dist/esm/components/Label/Label.js.map +1 -1
  5. package/dist/esm/components/Select/Select.d.ts +5 -1
  6. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  7. package/dist/esm/components/Select/Select.js +171 -28
  8. package/dist/esm/components/Select/Select.js.map +1 -1
  9. package/dist/esm/components/Select/SelectMenu.d.ts.map +1 -1
  10. package/dist/esm/components/Select/SelectMenu.js +2 -1
  11. package/dist/esm/components/Select/SelectMenu.js.map +1 -1
  12. package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
  13. package/dist/esm/components/Select/SelectOption.js +6 -1
  14. package/dist/esm/components/Select/SelectOption.js.map +1 -1
  15. package/dist/esm/components/Select/SelectToggle.d.ts +3 -2
  16. package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
  17. package/dist/esm/components/Select/SelectToggle.js +26 -16
  18. package/dist/esm/components/Select/SelectToggle.js.map +1 -1
  19. package/dist/esm/components/Select/selectConstants.d.ts +1 -0
  20. package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
  21. package/dist/esm/components/Select/selectConstants.js +1 -0
  22. package/dist/esm/components/Select/selectConstants.js.map +1 -1
  23. package/dist/esm/components/Tabs/Tabs.d.ts +2 -5
  24. package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
  25. package/dist/esm/components/Tabs/Tabs.js +3 -3
  26. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  27. package/dist/esm/components/TimePicker/TimePicker.d.ts +4 -6
  28. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  29. package/dist/esm/components/TimePicker/TimePicker.js +74 -42
  30. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  31. package/dist/esm/helpers/util.d.ts +6 -0
  32. package/dist/esm/helpers/util.d.ts.map +1 -1
  33. package/dist/esm/helpers/util.js +12 -0
  34. package/dist/esm/helpers/util.js.map +1 -1
  35. package/dist/js/components/Label/Label.d.ts.map +1 -1
  36. package/dist/js/components/Label/Label.js +38 -25
  37. package/dist/js/components/Label/Label.js.map +1 -1
  38. package/dist/js/components/Select/Select.d.ts +5 -1
  39. package/dist/js/components/Select/Select.d.ts.map +1 -1
  40. package/dist/js/components/Select/Select.js +170 -27
  41. package/dist/js/components/Select/Select.js.map +1 -1
  42. package/dist/js/components/Select/SelectMenu.d.ts.map +1 -1
  43. package/dist/js/components/Select/SelectMenu.js +2 -1
  44. package/dist/js/components/Select/SelectMenu.js.map +1 -1
  45. package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
  46. package/dist/js/components/Select/SelectOption.js +6 -1
  47. package/dist/js/components/Select/SelectOption.js.map +1 -1
  48. package/dist/js/components/Select/SelectToggle.d.ts +3 -2
  49. package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
  50. package/dist/js/components/Select/SelectToggle.js +25 -15
  51. package/dist/js/components/Select/SelectToggle.js.map +1 -1
  52. package/dist/js/components/Select/selectConstants.d.ts +1 -0
  53. package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
  54. package/dist/js/components/Select/selectConstants.js +2 -1
  55. package/dist/js/components/Select/selectConstants.js.map +1 -1
  56. package/dist/js/components/Tabs/Tabs.d.ts +2 -5
  57. package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
  58. package/dist/js/components/Tabs/Tabs.js +3 -3
  59. package/dist/js/components/Tabs/Tabs.js.map +1 -1
  60. package/dist/js/components/TimePicker/TimePicker.d.ts +4 -6
  61. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  62. package/dist/js/components/TimePicker/TimePicker.js +73 -41
  63. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  64. package/dist/js/helpers/util.d.ts +6 -0
  65. package/dist/js/helpers/util.d.ts.map +1 -1
  66. package/dist/js/helpers/util.js +14 -1
  67. package/dist/js/helpers/util.js.map +1 -1
  68. package/dist/umd/react-core.css +64 -110
  69. package/dist/umd/react-core.js +847 -653
  70. package/dist/umd/react-core.min.css +64 -110
  71. package/dist/umd/react-core.min.js +3 -3
  72. package/package.json +6 -6
  73. package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +1 -1
  74. package/src/components/ApplicationLauncher/examples/ApplicationLauncher.md +11 -577
  75. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignRight.tsx +32 -0
  76. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignTop.tsx +31 -0
  77. package/src/components/ApplicationLauncher/examples/ApplicationLauncherBasic.tsx +23 -0
  78. package/src/components/ApplicationLauncher/examples/ApplicationLauncherCustomIcon.tsx +32 -0
  79. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDisabled.tsx +25 -0
  80. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDocumentBody.tsx +31 -0
  81. package/src/components/ApplicationLauncher/examples/ApplicationLauncherFavoritesAndSearch.tsx +105 -0
  82. package/src/components/ApplicationLauncher/examples/ApplicationLauncherRouterLink.tsx +50 -0
  83. package/src/components/ApplicationLauncher/examples/ApplicationLauncherSectionsAndIcons.tsx +47 -0
  84. package/src/components/ApplicationLauncher/examples/ApplicationLauncherTooltip.tsx +35 -0
  85. package/src/components/Label/Label.tsx +58 -39
  86. package/src/components/Label/__tests__/Label.test.tsx +19 -1
  87. package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +109 -0
  88. package/src/components/Label/examples/Label.md +1 -41
  89. package/src/components/Label/examples/LabelEditable.tsx +57 -0
  90. package/src/components/Select/Select.tsx +166 -26
  91. package/src/components/Select/SelectMenu.tsx +2 -1
  92. package/src/components/Select/SelectOption.tsx +5 -1
  93. package/src/components/Select/SelectToggle.tsx +38 -17
  94. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +74 -24
  95. package/src/components/Select/examples/Select.md +5 -1
  96. package/src/components/Select/selectConstants.tsx +2 -0
  97. package/src/components/Tabs/Tabs.tsx +6 -9
  98. package/src/components/TimePicker/TimePicker.tsx +112 -124
  99. package/src/components/TimePicker/examples/TimePicker.md +16 -10
  100. package/src/helpers/util.ts +13 -0
@@ -1,5 +1,102 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`editable label 1`] = `
4
+ <Label
5
+ isEditable={true}
6
+ onClose={[MockFunction]}
7
+ onEditCancel={[MockFunction]}
8
+ onEditComplete={[MockFunction]}
9
+ >
10
+ <span
11
+ className="pf-c-label pf-m-editable"
12
+ >
13
+ <span
14
+ className="pf-c-label__content"
15
+ >
16
+ <button
17
+ className="pf-c-label__editable-text"
18
+ onClick={[Function]}
19
+ >
20
+ Something
21
+ </button>
22
+ </span>
23
+ <Button
24
+ aria-label="Close Something"
25
+ onClick={[MockFunction]}
26
+ type="button"
27
+ variant="plain"
28
+ >
29
+ <ButtonBase
30
+ aria-label="Close Something"
31
+ innerRef={null}
32
+ onClick={[MockFunction]}
33
+ type="button"
34
+ variant="plain"
35
+ >
36
+ <button
37
+ aria-disabled={false}
38
+ aria-label="Close Something"
39
+ className="pf-c-button pf-m-plain"
40
+ data-ouia-component-id="OUIA-Generated-Button-plain-1"
41
+ data-ouia-component-type="PF4/Button"
42
+ data-ouia-safe={true}
43
+ disabled={false}
44
+ onClick={[MockFunction]}
45
+ role={null}
46
+ type="button"
47
+ >
48
+ <TimesIcon
49
+ color="currentColor"
50
+ noVerticalAlign={false}
51
+ size="sm"
52
+ >
53
+ <svg
54
+ aria-hidden={true}
55
+ aria-labelledby={null}
56
+ fill="currentColor"
57
+ height="1em"
58
+ role="img"
59
+ style={
60
+ Object {
61
+ "verticalAlign": "-0.125em",
62
+ }
63
+ }
64
+ viewBox="0 0 352 512"
65
+ width="1em"
66
+ >
67
+ <path
68
+ d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
69
+ />
70
+ </svg>
71
+ </TimesIcon>
72
+ </button>
73
+ </ButtonBase>
74
+ </Button>
75
+ </span>
76
+ </Label>
77
+ `;
78
+
79
+ exports[`editable label 2`] = `
80
+ <Label
81
+ isEditable={true}
82
+ onClose={[MockFunction]}
83
+ onEditCancel={[MockFunction]}
84
+ onEditComplete={[MockFunction]}
85
+ >
86
+ <span
87
+ className="pf-c-label pf-m-editable pf-m-editable-active"
88
+ >
89
+ <input
90
+ className="pf-c-label__editable-text"
91
+ id="editable-input"
92
+ onChange={[Function]}
93
+ type="text"
94
+ value="Something"
95
+ />
96
+ </span>
97
+ </Label>
98
+ `;
99
+
3
100
  exports[`label 1`] = `
4
101
  <span
5
102
  className="pf-c-label"
@@ -24,6 +121,18 @@ exports[`label 2`] = `
24
121
  </span>
25
122
  `;
26
123
 
124
+ exports[`label 3`] = `
125
+ <span
126
+ className="pf-c-label pf-m-compact"
127
+ >
128
+ <span
129
+ className="pf-c-label__content"
130
+ >
131
+ Something
132
+ </span>
133
+ </span>
134
+ `;
135
+
27
136
  exports[`label with additional class name 1`] = `
28
137
  <span
29
138
  className="pf-c-label klass1"
@@ -386,45 +386,5 @@ Click or press either enter or space to begin editing a label. After editing, cl
386
386
 
387
387
  You can also customize any Label's close button aria-label as this example shows with `closeBtnAriaLabel`.
388
388
 
389
- ```js isBeta
390
- import React from 'react';
391
- import { Label } from '@patternfly/react-core';
392
-
393
- class EditableLabel extends React.Component {
394
- constructor(props) {
395
- super(props);
396
- this.state = {
397
- text: 'Editable label'
398
- };
399
- this.onEditCancel = prevText => {
400
- this.setState({
401
- text: prevText
402
- });
403
- };
404
- this.onEditComplete = newText => {
405
- this.setState({
406
- text: newText
407
- });
408
- };
409
- }
410
-
411
- render() {
412
- return (
413
- <Label
414
- color="blue"
415
- onClose={Function.prototype}
416
- closeBtnAriaLabel="Custom close button for editable label"
417
- onEditCancel={this.onEditCancel}
418
- onEditComplete={this.onEditComplete}
419
- isEditable
420
- editableProps={{
421
- 'aria-label': 'Editable text',
422
- id: 'editable-label'
423
- }}
424
- >
425
- {this.state.text}
426
- </Label>
427
- );
428
- }
429
- }
389
+ ```js file="LabelEditable.tsx" isBeta
430
390
  ```
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { Label } from '@patternfly/react-core';
3
+
4
+ export const LabelEditable: React.FunctionComponent = () => {
5
+ const [labelText, setLabelText] = React.useState('Editable label');
6
+ const [compactLabelText, setCompactLabelText] = React.useState('Compact editable label');
7
+
8
+ const onEditCancel = (prevText: string) => {
9
+ setLabelText(prevText);
10
+ };
11
+
12
+ const onEditComplete = (text: string) => {
13
+ setLabelText(text);
14
+ };
15
+
16
+ const onCompactEditCancel = (prevText: string) => {
17
+ setCompactLabelText(prevText);
18
+ };
19
+
20
+ const onCompactEditComplete = (text: string) => {
21
+ setCompactLabelText(text);
22
+ };
23
+
24
+ return (
25
+ <React.Fragment>
26
+ <Label
27
+ color="blue"
28
+ onClose={() => {}}
29
+ closeBtnAriaLabel="Custom close button for editable label"
30
+ onEditCancel={onEditCancel}
31
+ onEditComplete={onEditComplete}
32
+ isEditable
33
+ editableProps={{
34
+ 'aria-label': 'Editable text',
35
+ id: 'editable-label'
36
+ }}
37
+ >
38
+ {labelText}
39
+ </Label>
40
+ <Label
41
+ color="grey"
42
+ isCompact
43
+ onClose={() => {}}
44
+ closeBtnAriaLabel="Custom close button for compact editable label"
45
+ onEditCancel={onCompactEditCancel}
46
+ onEditComplete={onCompactEditComplete}
47
+ isEditable
48
+ editableProps={{
49
+ 'aria-label': 'Compact editable text',
50
+ id: 'compact-editable-label'
51
+ }}
52
+ >
53
+ {compactLabelText}
54
+ </Label>
55
+ </React.Fragment>
56
+ );
57
+ };
@@ -12,7 +12,14 @@ import { SelectMenu } from './SelectMenu';
12
12
  import { SelectOption, SelectOptionObject } from './SelectOption';
13
13
  import { SelectGroup, SelectGroupProps } from './SelectGroup';
14
14
  import { SelectToggle } from './SelectToggle';
15
- import { SelectContext, SelectVariant, SelectPosition, SelectDirection, KeyTypes } from './selectConstants';
15
+ import {
16
+ SelectContext,
17
+ SelectVariant,
18
+ SelectPosition,
19
+ SelectDirection,
20
+ KeyTypes,
21
+ SelectFooterTabbableItems
22
+ } from './selectConstants';
16
23
  import { Chip, ChipGroup, ChipGroupProps } from '../ChipGroup';
17
24
  import { Spinner } from '../Spinner';
18
25
  import {
@@ -24,10 +31,12 @@ import {
24
31
  PickOptional,
25
32
  GenerateId
26
33
  } from '../../helpers';
34
+ import { getUniqueId } from '../../helpers/util';
27
35
  import { Divider } from '../Divider';
28
36
  import { ToggleMenuBaseProps, Popper } from '../../helpers/Popper/Popper';
29
37
  import { createRenderableFavorites, extendItemsWithFavorite } from '../../helpers/favorites';
30
38
  import { ValidatedOptions } from '../../helpers/constants';
39
+ import { findTabbableElements } from '../../helpers/util';
31
40
 
32
41
  // seed for the aria-labelledby ID
33
42
  let currentId = 0;
@@ -140,6 +149,8 @@ export interface SelectProps
140
149
  customBadgeText?: string | number;
141
150
  /** Prefix for the id of the input in the checkbox select variant*/
142
151
  inputIdPrefix?: string;
152
+ /** Value for the typeahead and inline filtering input autocomplete attribute */
153
+ inputAutoComplete?: string;
143
154
  /** Optional props to pass to the chip group in the typeaheadmulti variant */
144
155
  chipGroupProps?: Omit<ChipGroupProps, 'children' | 'ref'>;
145
156
  /** Optional props to render custom chip group in the typeaheadmulti variant */
@@ -213,6 +224,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
213
224
  inlineFilterPlaceholderText: null,
214
225
  customBadgeText: null,
215
226
  inputIdPrefix: '',
227
+ inputAutoComplete: navigator.userAgent.match('Chrome') ? getUniqueId('pf-no-autocomplete') : 'off',
216
228
  menuAppendTo: 'inline',
217
229
  favorites: [] as string[],
218
230
  favoritesLabel: 'Favorites',
@@ -613,9 +625,42 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
613
625
  }));
614
626
  };
615
627
 
616
- handleTypeaheadKeys = (position: string) => {
628
+ switchFocusToFavoriteMenu = () => {
629
+ const { typeaheadCurrIndex, typeaheadStoredIndex } = this.state;
630
+ let indexForFocus = 0;
631
+
632
+ if (typeaheadCurrIndex !== -1) {
633
+ indexForFocus = typeaheadCurrIndex;
634
+ } else if (typeaheadStoredIndex !== -1) {
635
+ indexForFocus = typeaheadStoredIndex;
636
+ }
637
+
638
+ if (this.refCollection[indexForFocus] !== null && this.refCollection[indexForFocus][0] !== null) {
639
+ this.refCollection[indexForFocus][0].focus();
640
+ } else {
641
+ this.clearRef.current.focus();
642
+ }
643
+
644
+ this.setState({
645
+ tabbedIntoFavoritesMenu: true,
646
+ typeaheadCurrIndex: -1
647
+ });
648
+ };
649
+
650
+ moveFocusToLastMenuItem = () => {
651
+ const refCollectionLen = this.refCollection.length;
652
+ if (
653
+ refCollectionLen > 0 &&
654
+ this.refCollection[refCollectionLen - 1] !== null &&
655
+ this.refCollection[refCollectionLen - 1][0] !== null
656
+ ) {
657
+ this.refCollection[refCollectionLen - 1][0].focus();
658
+ }
659
+ };
660
+
661
+ handleTypeaheadKeys = (position: string, shiftKey: boolean = false) => {
617
662
  const { isOpen, onFavorite } = this.props;
618
- const { typeaheadCurrIndex, tabbedIntoFavoritesMenu, typeaheadStoredIndex } = this.state;
663
+ const { typeaheadCurrIndex, tabbedIntoFavoritesMenu } = this.state;
619
664
  const typeaheadActiveChild = this.getTypeaheadActiveChild(typeaheadCurrIndex);
620
665
 
621
666
  if (isOpen) {
@@ -633,30 +678,110 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
633
678
  }
634
679
  } else if (position === 'tab') {
635
680
  if (onFavorite) {
681
+ // if the input has focus, tab to the first item or the last item that was previously focused.
636
682
  if (this.inputRef.current === document.activeElement) {
637
- let indexForFocus = 0;
638
- if (typeaheadCurrIndex !== -1) {
639
- indexForFocus = typeaheadCurrIndex;
640
- } else if (typeaheadStoredIndex !== -1) {
641
- indexForFocus = typeaheadStoredIndex;
642
- }
643
-
644
- if (this.refCollection[indexForFocus] !== null && this.refCollection[indexForFocus][0] !== null) {
645
- this.refCollection[indexForFocus][0].focus();
683
+ // If shift is also clicked and there is a footer, tab to the last item in tabbable footer
684
+ if (this.props.footer && shiftKey) {
685
+ const tabbableItems = findTabbableElements(this.footerRef, SelectFooterTabbableItems);
686
+ if (tabbableItems.length > 0) {
687
+ if (tabbableItems[tabbableItems.length - 1]) {
688
+ tabbableItems[tabbableItems.length - 1].focus();
689
+ }
690
+ }
646
691
  } else {
647
- this.clearRef.current.focus();
692
+ this.switchFocusToFavoriteMenu();
648
693
  }
649
-
650
- this.setState({
651
- tabbedIntoFavoritesMenu: true,
652
- typeaheadCurrIndex: -1
653
- });
654
694
  } else {
655
- this.inputRef.current.focus();
656
- this.setState({ tabbedIntoFavoritesMenu: false });
695
+ // focus is on menu or footer
696
+ if (this.props.footer) {
697
+ let tabbedIntoMenu = false;
698
+ const tabbableItems = findTabbableElements(this.footerRef, SelectFooterTabbableItems);
699
+ if (tabbableItems.length > 0) {
700
+ // if current element is not in footer, tab to first tabbable element in footer,
701
+ // if shift was clicked, tab to input since focus is on menu
702
+ const currentElementIndex = tabbableItems.findIndex((item: any) => item === document.activeElement);
703
+ if (currentElementIndex === -1) {
704
+ if (shiftKey) {
705
+ // currently in menu, shift back to input
706
+ this.inputRef.current.focus();
707
+ } else {
708
+ // currently in menu, tab to first tabbable item in footer
709
+ tabbableItems[0].focus();
710
+ }
711
+ } else {
712
+ // already in footer
713
+ if (shiftKey) {
714
+ // shift to previous item
715
+ if (currentElementIndex === 0) {
716
+ // on first footer item, shift back to menu
717
+ this.switchFocusToFavoriteMenu();
718
+ tabbedIntoMenu = true;
719
+ } else {
720
+ // shift to previous footer item
721
+ tabbableItems[currentElementIndex - 1].focus();
722
+ }
723
+ } else {
724
+ // tab to next tabbable item in footer or to input.
725
+ if (tabbableItems[currentElementIndex + 1]) {
726
+ tabbableItems[currentElementIndex + 1].focus();
727
+ } else {
728
+ this.inputRef.current.focus();
729
+ }
730
+ }
731
+ }
732
+ } else {
733
+ // no tabbable items in footer, tab to input
734
+ this.inputRef.current.focus();
735
+ tabbedIntoMenu = false;
736
+ }
737
+ this.setState({ tabbedIntoFavoritesMenu: tabbedIntoMenu });
738
+ } else {
739
+ this.inputRef.current.focus();
740
+ this.setState({ tabbedIntoFavoritesMenu: false });
741
+ }
657
742
  }
658
743
  } else {
659
- this.onToggle(false);
744
+ // Close if there is no footer
745
+ if (!this.props.footer) {
746
+ this.onToggle(false);
747
+ } else {
748
+ // has footer
749
+ const tabbableItems = findTabbableElements(this.footerRef, SelectFooterTabbableItems);
750
+ const currentElementIndex = tabbableItems.findIndex((item: any) => item === document.activeElement);
751
+ if (this.inputRef.current === document.activeElement) {
752
+ if (shiftKey) {
753
+ // close toggle if shift key and tab on input
754
+ this.onToggle(false);
755
+ } else {
756
+ // tab to first tabbable item in footer
757
+ if (tabbableItems[0]) {
758
+ tabbableItems[0].focus();
759
+ } else {
760
+ this.onToggle(false);
761
+ }
762
+ }
763
+ } else {
764
+ // focus is in footer
765
+ if (shiftKey) {
766
+ if (currentElementIndex === 0) {
767
+ // shift tab back to input
768
+ this.inputRef.current.focus();
769
+ } else {
770
+ // shift to previous footer item
771
+ tabbableItems[currentElementIndex - 1].focus();
772
+ }
773
+ } else {
774
+ // tab to next footer item or close tab if last item
775
+ if (tabbableItems[currentElementIndex + 1]) {
776
+ tabbableItems[currentElementIndex + 1].focus();
777
+ } else {
778
+ // no next item, close toggle
779
+ this.onToggle(false);
780
+ this.inputRef.current.focus();
781
+ }
782
+ }
783
+ }
784
+ }
660
785
  }
661
786
  } else if (!tabbedIntoFavoritesMenu) {
662
787
  if (this.refCollection[0][0] === null) {
@@ -793,6 +918,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
793
918
  noResultsFoundText,
794
919
  customBadgeText,
795
920
  inputIdPrefix,
921
+ inputAutoComplete,
796
922
  /* eslint-disable @typescript-eslint/no-unused-vars */
797
923
  isInputValuePersisted,
798
924
  isInputFilterPersisted,
@@ -856,7 +982,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
856
982
  if (renderableItems.find(item => (item as any)?.key === 'loading') === undefined) {
857
983
  if (loadingVariant === 'spinner') {
858
984
  renderableItems.push(
859
- <SelectOption isLoading key="loading" value="loading" isGrouped>
985
+ <SelectOption isLoading key="loading" value="loading">
860
986
  <Spinner size="lg" />
861
987
  </SelectOption>
862
988
  );
@@ -866,7 +992,6 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
866
992
  isLoad
867
993
  key="loading"
868
994
  value={loadingVariant.text}
869
- isGrouped
870
995
  setViewMoreNextIndex={this.setVieMoreNextIndex}
871
996
  onClick={loadingVariant?.onClick}
872
997
  />
@@ -940,6 +1065,20 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
940
1065
  } else if (event.key === KeyTypes.ArrowRight) {
941
1066
  this.handleMenuKeys(0, 0, 'right');
942
1067
  event.preventDefault();
1068
+ } else if (event.key === KeyTypes.Tab && variant !== SelectVariant.checkbox && this.props.footer) {
1069
+ // tab to footer or close menu if shift key
1070
+ if (event.shiftKey) {
1071
+ this.onToggle(false);
1072
+ } else {
1073
+ const tabbableItems = findTabbableElements(this.footerRef, SelectFooterTabbableItems);
1074
+ if (tabbableItems.length > 0) {
1075
+ tabbableItems[0].focus();
1076
+ event.stopPropagation();
1077
+ event.preventDefault();
1078
+ } else {
1079
+ this.onToggle(false);
1080
+ }
1081
+ }
943
1082
  } else if (event.key === KeyTypes.Tab && variant === SelectVariant.checkbox) {
944
1083
  // More modal-like experience for checkboxes
945
1084
  // Let SelectOption handle this
@@ -953,7 +1092,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
953
1092
  }
954
1093
  }}
955
1094
  ref={this.filterRef}
956
- autoComplete="never"
1095
+ autoComplete={inputAutoComplete}
957
1096
  />
958
1097
  </div>
959
1098
  <Divider key="inline-filter-divider" />
@@ -1091,6 +1230,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1091
1230
  aria-labelledby={`${ariaLabelledBy || ''} ${selectToggleId}`}
1092
1231
  aria-label={toggleAriaLabel}
1093
1232
  handleTypeaheadKeys={this.handleTypeaheadKeys}
1233
+ moveFocusToLastMenuItem={this.moveFocusToLastMenuItem}
1094
1234
  isDisabled={isDisabled}
1095
1235
  hasClearButton={hasOnClear}
1096
1236
  hasFooter={footer !== undefined}
@@ -1147,7 +1287,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1147
1287
  type="text"
1148
1288
  onClick={this.onClick}
1149
1289
  onChange={this.onChange}
1150
- autoComplete="never"
1290
+ autoComplete={inputAutoComplete}
1151
1291
  disabled={isDisabled}
1152
1292
  ref={this.inputRef}
1153
1293
  />
@@ -1171,7 +1311,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
1171
1311
  type="text"
1172
1312
  onChange={this.onChange}
1173
1313
  onClick={this.onClick}
1174
- autoComplete="never"
1314
+ autoComplete={inputAutoComplete}
1175
1315
  disabled={isDisabled}
1176
1316
  ref={this.inputRef}
1177
1317
  />
@@ -152,7 +152,8 @@ class SelectMenuWithRef extends React.Component<SelectMenuProps> {
152
152
  isChecked: this.checkForValue(option.props.value, checked),
153
153
  sendRef,
154
154
  keyHandler,
155
- index: index++
155
+ index: index++,
156
+ isLastOptionBeforeFooter
156
157
  })
157
158
  )}
158
159
  </fieldset>
@@ -134,7 +134,11 @@ export class SelectOption extends React.Component<SelectOptionProps> {
134
134
  }
135
135
  event.stopPropagation();
136
136
  } else {
137
- keyHandler(index, innerIndex, 'tab');
137
+ if (event.shiftKey) {
138
+ keyHandler(index, innerIndex, 'up');
139
+ } else {
140
+ keyHandler(index, innerIndex, 'tab');
141
+ }
138
142
  }
139
143
  }
140
144
  event.preventDefault();
@@ -3,8 +3,9 @@ import styles from '@patternfly/react-styles/css/components/Select/select';
3
3
  import buttonStyles from '@patternfly/react-styles/css/components/Button/button';
4
4
  import { css } from '@patternfly/react-styles';
5
5
  import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
6
- import { KeyTypes, SelectVariant } from './selectConstants';
6
+ import { KeyTypes, SelectVariant, SelectFooterTabbableItems } from './selectConstants';
7
7
  import { PickOptional } from '../../helpers/typeUtils';
8
+ import { findTabbableElements } from '../../helpers/util';
8
9
 
9
10
  export interface SelectToggleProps extends React.HTMLProps<HTMLElement> {
10
11
  /** HTML ID of dropdown toggle */
@@ -22,7 +23,9 @@ export interface SelectToggleProps extends React.HTMLProps<HTMLElement> {
22
23
  /** Callback for toggle close */
23
24
  onClose?: () => void;
24
25
  /** @hide Internal callback for toggle keyboard navigation */
25
- handleTypeaheadKeys?: (position: string) => void;
26
+ handleTypeaheadKeys?: (position: string, shiftKey?: boolean) => void;
27
+ /** @hide Internal callback to move focus to last menu item */
28
+ moveFocusToLastMenuItem?: () => void;
26
29
  /** Element which wraps toggle */
27
30
  parentRef: React.RefObject<HTMLDivElement>;
28
31
  /** The menu element */
@@ -106,16 +109,18 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
106
109
  }
107
110
  };
108
111
 
109
- findTabbableFooterElements = () => {
110
- const tabbable = this.props.footerRef.current.querySelectorAll('input, button, select, textarea, a[href]');
111
- const list = Array.prototype.filter.call(tabbable, function(item) {
112
- return item.tabIndex >= '0';
113
- });
114
- return list;
115
- };
116
-
117
112
  handleGlobalKeys = (event: KeyboardEvent) => {
118
- const { parentRef, menuRef, hasFooter, isOpen, variant, onToggle, onClose } = this.props;
113
+ const {
114
+ parentRef,
115
+ menuRef,
116
+ hasFooter,
117
+ footerRef,
118
+ isOpen,
119
+ variant,
120
+ onToggle,
121
+ onClose,
122
+ moveFocusToLastMenuItem
123
+ } = this.props;
119
124
  const escFromToggle = parentRef && parentRef.current && parentRef.current.contains(event.target as Node);
120
125
  const escFromWithinMenu =
121
126
  menuRef && menuRef.current && menuRef.current.contains && menuRef.current.contains(event.target as Node);
@@ -124,13 +129,13 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
124
129
  event.key === KeyTypes.Tab &&
125
130
  (variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti)
126
131
  ) {
127
- this.props.handleTypeaheadKeys('tab');
132
+ this.props.handleTypeaheadKeys('tab', event.shiftKey);
128
133
  event.preventDefault();
129
134
  return;
130
135
  }
131
136
 
132
137
  if (isOpen && event.key === KeyTypes.Tab && hasFooter) {
133
- const tabbableItems = this.findTabbableFooterElements();
138
+ const tabbableItems = findTabbableElements(footerRef, SelectFooterTabbableItems);
134
139
 
135
140
  // If no tabbable item in footer close select
136
141
  if (tabbableItems.length <= 0) {
@@ -139,14 +144,29 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
139
144
  this.toggle.current.focus();
140
145
  return;
141
146
  } else {
142
- // if current element is not in footer, tab to first tabbable element in footer
143
- const currentElementIndex = tabbableItems.findIndex(item => item === document.activeElement);
147
+ // if current element is not in footer, tab to first tabbable element in footer, or close if shift clicked
148
+ const currentElementIndex = tabbableItems.findIndex((item: any) => item === document.activeElement);
144
149
  if (currentElementIndex === -1) {
145
- tabbableItems[0].focus();
146
- return;
150
+ if (event.shiftKey) {
151
+ if (variant !== 'checkbox') {
152
+ // only close non checkbox variation on shift clicked
153
+ onToggle(false);
154
+ onClose();
155
+ this.toggle.current.focus();
156
+ }
157
+ } else {
158
+ // tab to footer
159
+ tabbableItems[0].focus();
160
+ return;
161
+ }
147
162
  }
148
163
  // Current element is in footer.
149
164
  if (event.shiftKey) {
165
+ // Move focus back to menuif current tab index is 0
166
+ if (currentElementIndex === 0) {
167
+ moveFocusToLastMenuItem();
168
+ event.preventDefault();
169
+ }
150
170
  return;
151
171
  }
152
172
  // Tab to next element in footer or close if there are none
@@ -225,6 +245,7 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
225
245
  onClose,
226
246
  onClickTypeaheadToggleButton,
227
247
  handleTypeaheadKeys,
248
+ moveFocusToLastMenuItem,
228
249
  parentRef,
229
250
  menuRef,
230
251
  id,