@atlaskit/react-select 3.3.0 → 3.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/react-select
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#192272](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/192272)
8
+ [`94b0093816679`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94b0093816679) -
9
+ conditionally handle the blur & menu close for the select based on the focusable elements other
10
+ than options
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 3.3.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 3.3.0
4
23
 
5
24
  ### Minor Changes
@@ -52,6 +52,7 @@ var defaultProps = exports.defaultProps = {
52
52
  isMulti: false,
53
53
  isRtl: false,
54
54
  isSearchable: true,
55
+ hasOtherFocusableElements: false,
55
56
  isOptionDisabled: _builtins.isOptionDisabled,
56
57
  loadingMessage: function loadingMessage() {
57
58
  return 'Loading...';
@@ -257,6 +258,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
257
258
  (0, _defineProperty2.default)(_this, "initialTouchY", 0);
258
259
  (0, _defineProperty2.default)(_this, "openAfterFocus", false);
259
260
  (0, _defineProperty2.default)(_this, "scrollToFocusedOptionOnUpdate", false);
261
+ (0, _defineProperty2.default)(_this, "lastPressedKey", '');
260
262
  // Refs
261
263
  // ------------------------------
262
264
  (0, _defineProperty2.default)(_this, "controlRef", null);
@@ -630,7 +632,9 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
630
632
  return;
631
633
  }
632
634
  if (_this.props.onBlur) {
633
- _this.props.onBlur(event);
635
+ if (!_this.props.hasOtherFocusableElements || _this.props.hasOtherFocusableElements && _this.lastPressedKey !== 'Tab') {
636
+ _this.props.onBlur(event);
637
+ }
634
638
  }
635
639
  _this.onInputChange('', {
636
640
  action: 'input-blur',
@@ -696,6 +700,9 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
696
700
  return;
697
701
  }
698
702
  }
703
+ if (_this.props.hasOtherFocusableElements) {
704
+ _this.lastPressedKey = event.key;
705
+ }
699
706
 
700
707
  // Block option hover events when the user has just pressed a key
701
708
  _this.blockOptionHover = true;
@@ -921,11 +928,15 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
921
928
  }, {
922
929
  key: "onMenuClose",
923
930
  value: function onMenuClose() {
924
- this.onInputChange('', {
925
- action: 'menu-close',
926
- prevInputValue: this.props.inputValue
927
- });
928
- this.props.onMenuClose();
931
+ if (!this.props.hasOtherFocusableElements || this.props.hasOtherFocusableElements && this.lastPressedKey !== 'Tab') {
932
+ this.onInputChange('', {
933
+ action: 'menu-close',
934
+ prevInputValue: this.props.inputValue
935
+ });
936
+ this.props.onMenuClose();
937
+ } else {
938
+ this.lastPressedKey = '';
939
+ }
929
940
  }
930
941
  }, {
931
942
  key: "onInputChange",
@@ -31,6 +31,7 @@ export const defaultProps = {
31
31
  isMulti: false,
32
32
  isRtl: false,
33
33
  isSearchable: true,
34
+ hasOtherFocusableElements: false,
34
35
  isOptionDisabled: isOptionDisabledBuiltin,
35
36
  loadingMessage: () => 'Loading...',
36
37
  maxMenuHeight: 300,
@@ -226,6 +227,7 @@ export default class Select extends Component {
226
227
  _defineProperty(this, "initialTouchY", 0);
227
228
  _defineProperty(this, "openAfterFocus", false);
228
229
  _defineProperty(this, "scrollToFocusedOptionOnUpdate", false);
230
+ _defineProperty(this, "lastPressedKey", '');
229
231
  // Refs
230
232
  // ------------------------------
231
233
  _defineProperty(this, "controlRef", null);
@@ -603,7 +605,9 @@ export default class Select extends Component {
603
605
  return;
604
606
  }
605
607
  if (this.props.onBlur) {
606
- this.props.onBlur(event);
608
+ if (!this.props.hasOtherFocusableElements || this.props.hasOtherFocusableElements && this.lastPressedKey !== 'Tab') {
609
+ this.props.onBlur(event);
610
+ }
607
611
  }
608
612
  this.onInputChange('', {
609
613
  action: 'input-blur',
@@ -671,6 +675,9 @@ export default class Select extends Component {
671
675
  return;
672
676
  }
673
677
  }
678
+ if (this.props.hasOtherFocusableElements) {
679
+ this.lastPressedKey = event.key;
680
+ }
674
681
 
675
682
  // Block option hover events when the user has just pressed a key
676
683
  this.blockOptionHover = true;
@@ -953,11 +960,15 @@ export default class Select extends Component {
953
960
  this.props.onMenuOpen();
954
961
  }
955
962
  onMenuClose() {
956
- this.onInputChange('', {
957
- action: 'menu-close',
958
- prevInputValue: this.props.inputValue
959
- });
960
- this.props.onMenuClose();
963
+ if (!this.props.hasOtherFocusableElements || this.props.hasOtherFocusableElements && this.lastPressedKey !== 'Tab') {
964
+ this.onInputChange('', {
965
+ action: 'menu-close',
966
+ prevInputValue: this.props.inputValue
967
+ });
968
+ this.props.onMenuClose();
969
+ } else {
970
+ this.lastPressedKey = '';
971
+ }
961
972
  }
962
973
  onInputChange(newValue, actionMeta) {
963
974
  this.props.onInputChange(newValue, actionMeta);
@@ -43,6 +43,7 @@ export var defaultProps = {
43
43
  isMulti: false,
44
44
  isRtl: false,
45
45
  isSearchable: true,
46
+ hasOtherFocusableElements: false,
46
47
  isOptionDisabled: isOptionDisabledBuiltin,
47
48
  loadingMessage: function loadingMessage() {
48
49
  return 'Loading...';
@@ -248,6 +249,7 @@ var Select = /*#__PURE__*/function (_Component) {
248
249
  _defineProperty(_this, "initialTouchY", 0);
249
250
  _defineProperty(_this, "openAfterFocus", false);
250
251
  _defineProperty(_this, "scrollToFocusedOptionOnUpdate", false);
252
+ _defineProperty(_this, "lastPressedKey", '');
251
253
  // Refs
252
254
  // ------------------------------
253
255
  _defineProperty(_this, "controlRef", null);
@@ -621,7 +623,9 @@ var Select = /*#__PURE__*/function (_Component) {
621
623
  return;
622
624
  }
623
625
  if (_this.props.onBlur) {
624
- _this.props.onBlur(event);
626
+ if (!_this.props.hasOtherFocusableElements || _this.props.hasOtherFocusableElements && _this.lastPressedKey !== 'Tab') {
627
+ _this.props.onBlur(event);
628
+ }
625
629
  }
626
630
  _this.onInputChange('', {
627
631
  action: 'input-blur',
@@ -687,6 +691,9 @@ var Select = /*#__PURE__*/function (_Component) {
687
691
  return;
688
692
  }
689
693
  }
694
+ if (_this.props.hasOtherFocusableElements) {
695
+ _this.lastPressedKey = event.key;
696
+ }
690
697
 
691
698
  // Block option hover events when the user has just pressed a key
692
699
  _this.blockOptionHover = true;
@@ -912,11 +919,15 @@ var Select = /*#__PURE__*/function (_Component) {
912
919
  }, {
913
920
  key: "onMenuClose",
914
921
  value: function onMenuClose() {
915
- this.onInputChange('', {
916
- action: 'menu-close',
917
- prevInputValue: this.props.inputValue
918
- });
919
- this.props.onMenuClose();
922
+ if (!this.props.hasOtherFocusableElements || this.props.hasOtherFocusableElements && this.lastPressedKey !== 'Tab') {
923
+ this.onInputChange('', {
924
+ action: 'menu-close',
925
+ prevInputValue: this.props.inputValue
926
+ });
927
+ this.props.onMenuClose();
928
+ } else {
929
+ this.lastPressedKey = '';
930
+ }
920
931
  }
921
932
  }, {
922
933
  key: "onInputChange",
@@ -240,6 +240,10 @@ export interface SelectProps<Option, IsMulti extends boolean, Group extends Grou
240
240
  * Whether to enable search functionality
241
241
  */
242
242
  isSearchable: boolean;
243
+ /**
244
+ * Indicate whether menu contains other focusable elements, like footer or header
245
+ */
246
+ hasOtherFocusableElements?: boolean;
243
247
  /**
244
248
  * This sets the aria-label attribute. It sets an accessible name for the select, for people who use assistive technology. Use of a visible label is highly recommended for greater accessibility support.
245
249
  */
@@ -449,6 +453,7 @@ export declare const defaultProps: {
449
453
  isMulti: boolean;
450
454
  isRtl: boolean;
451
455
  isSearchable: boolean;
456
+ hasOtherFocusableElements: boolean;
452
457
  isOptionDisabled: <Option_3>(option: Option_3) => boolean;
453
458
  loadingMessage: () => string;
454
459
  maxMenuHeight: number;
@@ -528,6 +533,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
528
533
  isMulti: boolean;
529
534
  isRtl: boolean;
530
535
  isSearchable: boolean;
536
+ hasOtherFocusableElements: boolean;
531
537
  isOptionDisabled: <Option_4>(option: Option_4) => boolean;
532
538
  loadingMessage: () => string;
533
539
  maxMenuHeight: number;
@@ -560,6 +566,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
560
566
  openAfterFocus: boolean;
561
567
  scrollToFocusedOptionOnUpdate: boolean;
562
568
  userIsDragging?: boolean;
569
+ lastPressedKey?: string;
563
570
  controlRef: HTMLDivElement | null;
564
571
  getControlRef: RefCallback<HTMLDivElement>;
565
572
  focusedOptionRef: HTMLDivElement | null;
@@ -240,6 +240,10 @@ export interface SelectProps<Option, IsMulti extends boolean, Group extends Grou
240
240
  * Whether to enable search functionality
241
241
  */
242
242
  isSearchable: boolean;
243
+ /**
244
+ * Indicate whether menu contains other focusable elements, like footer or header
245
+ */
246
+ hasOtherFocusableElements?: boolean;
243
247
  /**
244
248
  * This sets the aria-label attribute. It sets an accessible name for the select, for people who use assistive technology. Use of a visible label is highly recommended for greater accessibility support.
245
249
  */
@@ -449,6 +453,7 @@ export declare const defaultProps: {
449
453
  isMulti: boolean;
450
454
  isRtl: boolean;
451
455
  isSearchable: boolean;
456
+ hasOtherFocusableElements: boolean;
452
457
  isOptionDisabled: <Option_3>(option: Option_3) => boolean;
453
458
  loadingMessage: () => string;
454
459
  maxMenuHeight: number;
@@ -528,6 +533,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
528
533
  isMulti: boolean;
529
534
  isRtl: boolean;
530
535
  isSearchable: boolean;
536
+ hasOtherFocusableElements: boolean;
531
537
  isOptionDisabled: <Option_4>(option: Option_4) => boolean;
532
538
  loadingMessage: () => string;
533
539
  maxMenuHeight: number;
@@ -560,6 +566,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
560
566
  openAfterFocus: boolean;
561
567
  scrollToFocusedOptionOnUpdate: boolean;
562
568
  userIsDragging?: boolean;
569
+ lastPressedKey?: string;
563
570
  controlRef: HTMLDivElement | null;
564
571
  getControlRef: RefCallback<HTMLDivElement>;
565
572
  focusedOptionRef: HTMLDivElement | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-select",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "A forked version of react-select to only be used in atlaskit/select",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/ds-lib": "^5.0.0",
32
- "@atlaskit/icon": "^27.7.0",
32
+ "@atlaskit/icon": "^27.8.0",
33
33
  "@atlaskit/layering": "^3.0.0",
34
34
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
- "@atlaskit/primitives": "^14.10.0",
36
- "@atlaskit/spinner": "^18.0.0",
35
+ "@atlaskit/primitives": "^14.11.0",
36
+ "@atlaskit/spinner": "^19.0.0",
37
37
  "@atlaskit/tokens": "^5.6.0",
38
38
  "@babel/runtime": "^7.0.0",
39
39
  "@compiled/react": "^0.18.3",