@dhis2-ui/select 10.16.1 → 10.16.2

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.
@@ -122,7 +122,6 @@ class Select extends _react.Component {
122
122
  keyCode
123
123
  } = e;
124
124
  const shouldOpen = !open && (keyCode === SPACE_KEY || keyCode === UP_KEY || keyCode === DOWN_KEY);
125
- const shouldClose = open && (keyCode === ESCAPE_KEY || keyCode === TAB_KEY);
126
125
 
127
126
  /* Do not block event propagation when the Select is closed unless
128
127
  * the key to open it is pressed, so that other components like
@@ -130,9 +129,13 @@ class Select extends _react.Component {
130
129
  if (open || shouldOpen) {
131
130
  e.stopPropagation();
132
131
  }
133
- if (shouldClose) {
132
+ if (open && keyCode === ESCAPE_KEY) {
134
133
  return this.handleClose();
135
134
  }
135
+ if (open && keyCode === TAB_KEY) {
136
+ // Defer so Tab advances focus before the menu unmounts.
137
+ return requestAnimationFrame(this.handleClose);
138
+ }
136
139
  if (shouldOpen) {
137
140
  return this.handleOpen();
138
141
  }
@@ -62,9 +62,9 @@ function useHandleKeyPressOnFilterInput(_ref) {
62
62
  altKey
63
63
  } = e;
64
64
 
65
- // Filter input stops propagation, so handle Tab here to close the menu.
65
+ // Defer so Tab advances focus before the filter unmounts.
66
66
  if (key === 'Tab') {
67
- closeMenu();
67
+ requestAnimationFrame(closeMenu);
68
68
  return;
69
69
  }
70
70
  if (key === 'Escape' || key === 'Enter' || key === 'ArrowUp' && altKey || key === 'ArrowDown' && altKey) {
@@ -114,7 +114,6 @@ export class Select extends Component {
114
114
  keyCode
115
115
  } = e;
116
116
  const shouldOpen = !open && (keyCode === SPACE_KEY || keyCode === UP_KEY || keyCode === DOWN_KEY);
117
- const shouldClose = open && (keyCode === ESCAPE_KEY || keyCode === TAB_KEY);
118
117
 
119
118
  /* Do not block event propagation when the Select is closed unless
120
119
  * the key to open it is pressed, so that other components like
@@ -122,9 +121,13 @@ export class Select extends Component {
122
121
  if (open || shouldOpen) {
123
122
  e.stopPropagation();
124
123
  }
125
- if (shouldClose) {
124
+ if (open && keyCode === ESCAPE_KEY) {
126
125
  return this.handleClose();
127
126
  }
127
+ if (open && keyCode === TAB_KEY) {
128
+ // Defer so Tab advances focus before the menu unmounts.
129
+ return requestAnimationFrame(this.handleClose);
130
+ }
128
131
  if (shouldOpen) {
129
132
  return this.handleOpen();
130
133
  }
@@ -56,9 +56,9 @@ export function useHandleKeyPressOnFilterInput(_ref) {
56
56
  altKey
57
57
  } = e;
58
58
 
59
- // Filter input stops propagation, so handle Tab here to close the menu.
59
+ // Defer so Tab advances focus before the filter unmounts.
60
60
  if (key === 'Tab') {
61
- closeMenu();
61
+ requestAnimationFrame(closeMenu);
62
62
  return;
63
63
  }
64
64
  if (key === 'Escape' || key === 'Enter' || key === 'ArrowUp' && altKey || key === 'ArrowDown' && altKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/select",
3
- "version": "10.16.1",
3
+ "version": "10.16.2",
4
4
  "description": "UI Select",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,21 +33,21 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/box": "10.16.1",
37
- "@dhis2-ui/button": "10.16.1",
38
- "@dhis2-ui/card": "10.16.1",
39
- "@dhis2-ui/checkbox": "10.16.1",
40
- "@dhis2-ui/chip": "10.16.1",
41
- "@dhis2-ui/field": "10.16.1",
42
- "@dhis2-ui/input": "10.16.1",
43
- "@dhis2-ui/layer": "10.16.1",
44
- "@dhis2-ui/loader": "10.16.1",
45
- "@dhis2-ui/popper": "10.16.1",
46
- "@dhis2-ui/status-icon": "10.16.1",
47
- "@dhis2-ui/tooltip": "10.16.1",
36
+ "@dhis2-ui/box": "10.16.2",
37
+ "@dhis2-ui/button": "10.16.2",
38
+ "@dhis2-ui/card": "10.16.2",
39
+ "@dhis2-ui/checkbox": "10.16.2",
40
+ "@dhis2-ui/chip": "10.16.2",
41
+ "@dhis2-ui/field": "10.16.2",
42
+ "@dhis2-ui/input": "10.16.2",
43
+ "@dhis2-ui/layer": "10.16.2",
44
+ "@dhis2-ui/loader": "10.16.2",
45
+ "@dhis2-ui/popper": "10.16.2",
46
+ "@dhis2-ui/status-icon": "10.16.2",
47
+ "@dhis2-ui/tooltip": "10.16.2",
48
48
  "@dhis2/prop-types": "^3.1.2",
49
- "@dhis2/ui-constants": "10.16.1",
50
- "@dhis2/ui-icons": "10.16.1",
49
+ "@dhis2/ui-constants": "10.16.2",
50
+ "@dhis2/ui-icons": "10.16.2",
51
51
  "classnames": "^2.3.1",
52
52
  "prop-types": "^15.7.2"
53
53
  },