@dhis2-ui/selector-bar 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.
@@ -49,10 +49,19 @@ const SelectorBarItem = _ref => {
49
49
  } = _ref;
50
50
  const buttonRef = (0, _react.useRef)();
51
51
  const Icon = open ? _uiIcons.IconChevronUp24 : _uiIcons.IconChevronDown24;
52
+ const handleKeyDown = evt => {
53
+ if (open && setOpen && evt.key === 'Tab') {
54
+ var _buttonRef$current;
55
+ // Move focus to trigger and defer close so Tab advances before the popup unmounts.
56
+ (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
57
+ requestAnimationFrame(() => setOpen(false));
58
+ }
59
+ };
52
60
  return /*#__PURE__*/_react.default.createElement("button", {
53
61
  ref: buttonRef,
54
62
  disabled: disabled,
55
63
  onClick: () => setOpen && setOpen(true),
64
+ onKeyDown: handleKeyDown,
56
65
  "data-test": dataTest,
57
66
  className: _style.default.dynamic([["4226485334", [
58
67
  /*
@@ -40,10 +40,19 @@ export const SelectorBarItem = _ref => {
40
40
  } = _ref;
41
41
  const buttonRef = useRef();
42
42
  const Icon = open ? IconChevronUp24 : IconChevronDown24;
43
+ const handleKeyDown = evt => {
44
+ if (open && setOpen && evt.key === 'Tab') {
45
+ var _buttonRef$current;
46
+ // Move focus to trigger and defer close so Tab advances before the popup unmounts.
47
+ (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
48
+ requestAnimationFrame(() => setOpen(false));
49
+ }
50
+ };
43
51
  return /*#__PURE__*/React.createElement("button", {
44
52
  ref: buttonRef,
45
53
  disabled: disabled,
46
54
  onClick: () => setOpen && setOpen(true),
55
+ onKeyDown: handleKeyDown,
47
56
  "data-test": dataTest,
48
57
  className: _JSXStyle.dynamic([["4226485334", [
49
58
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/selector-bar",
3
- "version": "10.16.1",
3
+ "version": "10.16.2",
4
4
  "description": "UI Select",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,20 +33,20 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/button": "10.16.1",
37
- "@dhis2-ui/card": "10.16.1",
38
- "@dhis2-ui/popper": "10.16.1",
39
- "@dhis2-ui/layer": "10.16.1",
40
- "@dhis2/ui-constants": "10.16.1",
41
- "@dhis2/ui-icons": "10.16.1",
36
+ "@dhis2-ui/button": "10.16.2",
37
+ "@dhis2-ui/card": "10.16.2",
38
+ "@dhis2-ui/popper": "10.16.2",
39
+ "@dhis2-ui/layer": "10.16.2",
40
+ "@dhis2/ui-constants": "10.16.2",
41
+ "@dhis2/ui-icons": "10.16.2",
42
42
  "classnames": "^2.3.1",
43
43
  "prop-types": "^15.7.2"
44
44
  },
45
45
  "devDependencies": {
46
- "@dhis2-ui/css": "10.16.1",
47
- "@dhis2-ui/menu": "10.16.1",
48
- "@dhis2-ui/organisation-unit-tree": "10.16.1",
49
- "@dhis2-ui/select": "10.16.1",
46
+ "@dhis2-ui/css": "10.16.2",
47
+ "@dhis2-ui/menu": "10.16.2",
48
+ "@dhis2-ui/organisation-unit-tree": "10.16.2",
49
+ "@dhis2-ui/select": "10.16.2",
50
50
  "@dhis2/d2-i18n": "^1.1.0",
51
51
  "react": "^18.3.1",
52
52
  "react-dom": "^18.3.1",