@atlaskit/dropdown-menu 12.23.2 → 12.23.3
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 +8 -0
- package/dist/cjs/dropdown-menu-item.js +3 -1
- package/dist/cjs/internal/hooks/use-register-item-with-focus-manager.js +7 -2
- package/dist/cjs/internal/utils/handle-focus.js +1 -2
- package/dist/es2019/dropdown-menu-item.js +3 -1
- package/dist/es2019/internal/hooks/use-register-item-with-focus-manager.js +8 -2
- package/dist/esm/dropdown-menu-item.js +3 -1
- package/dist/esm/internal/hooks/use-register-item-with-focus-manager.js +7 -2
- package/dist/esm/internal/utils/handle-focus.js +1 -2
- package/dist/types/internal/hooks/use-register-item-with-focus-manager.d.ts +1 -1
- package/dist/types/types.d.ts +4 -0
- package/dist/types-ts4.5/internal/hooks/use-register-item-with-focus-manager.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/package.json +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 12.23.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#179984](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/179984)
|
|
8
|
+
[`08accf7fa1041`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/08accf7fa1041) -
|
|
9
|
+
Fix keyboard navigation not working when using dropdown menu item as the nested trigger
|
|
10
|
+
|
|
3
11
|
## 12.23.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -48,7 +48,9 @@ var DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
48
48
|
returnFocusRef = _ref.returnFocusRef,
|
|
49
49
|
interactionName = _ref.interactionName,
|
|
50
50
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
51
|
-
|
|
51
|
+
// if the dropdown item has aria-haspopup, we won't register with focus manager
|
|
52
|
+
// since it is a nested trigger, we have registered inside dropdown-menu
|
|
53
|
+
var itemRef = (0, _useRegisterItemWithFocusManager.default)(!!rest['aria-haspopup']);
|
|
52
54
|
var handleItemClick = (0, _react.useCallback)(function (event) {
|
|
53
55
|
if (returnFocusRef !== null && returnFocusRef !== void 0 && returnFocusRef.current) {
|
|
54
56
|
returnFocusRef.current.focus();
|
|
@@ -5,17 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
9
|
var _focusManager = require("../components/focus-manager");
|
|
9
10
|
// This function is called whenever a MenuItem mounts.
|
|
10
11
|
// The refs stored in the context are used to programmatically
|
|
11
12
|
// control focus on a user navigates using the keyboard.
|
|
12
13
|
function useRegisterItemWithFocusManager() {
|
|
14
|
+
var hasPopup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
13
15
|
var _useContext = (0, _react.useContext)(_focusManager.FocusManagerContext),
|
|
14
16
|
registerRef = _useContext.registerRef;
|
|
15
17
|
var itemRef = (0, _react.useRef)(null);
|
|
16
18
|
(0, _react.useEffect)(function () {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
if (hasPopup && (0, _platformFeatureFlags.fg)('select-avoid-duplicated-registered-ref')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
registerRef(itemRef);
|
|
23
|
+
}, [registerRef, hasPopup]);
|
|
19
24
|
return itemRef;
|
|
20
25
|
}
|
|
21
26
|
var _default = exports.default = useRegisterItemWithFocusManager;
|
|
@@ -9,8 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _keycodes = require("@atlaskit/ds-lib/keycodes");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
11
|
var _useGeneratedId = require("./use-generated-id");
|
|
12
|
-
var
|
|
13
|
-
var actionMap = (_actionMap = {}, (0, _defineProperty2.default)(_actionMap, _keycodes.KEY_DOWN, 'next'), (0, _defineProperty2.default)(_actionMap, _keycodes.KEY_UP, 'prev'), (0, _defineProperty2.default)(_actionMap, _keycodes.KEY_HOME, 'first'), (0, _defineProperty2.default)(_actionMap, _keycodes.KEY_END, 'last'), _actionMap);
|
|
12
|
+
var actionMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keycodes.KEY_DOWN, 'next'), _keycodes.KEY_UP, 'prev'), _keycodes.KEY_HOME, 'first'), _keycodes.KEY_END, 'last');
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* `currentFocusedIdx + 1` will not work if the next focusable element
|
|
@@ -35,7 +35,9 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef(({
|
|
|
35
35
|
interactionName,
|
|
36
36
|
...rest
|
|
37
37
|
}, ref) => {
|
|
38
|
-
|
|
38
|
+
// if the dropdown item has aria-haspopup, we won't register with focus manager
|
|
39
|
+
// since it is a nested trigger, we have registered inside dropdown-menu
|
|
40
|
+
const itemRef = useRegisterItemWithFocusManager(!!rest['aria-haspopup']);
|
|
39
41
|
const handleItemClick = useCallback(event => {
|
|
40
42
|
if (returnFocusRef !== null && returnFocusRef !== void 0 && returnFocusRef.current) {
|
|
41
43
|
returnFocusRef.current.focus();
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { FocusManagerContext } from '../components/focus-manager';
|
|
3
4
|
// This function is called whenever a MenuItem mounts.
|
|
4
5
|
// The refs stored in the context are used to programmatically
|
|
5
6
|
// control focus on a user navigates using the keyboard.
|
|
6
|
-
function useRegisterItemWithFocusManager() {
|
|
7
|
+
function useRegisterItemWithFocusManager(hasPopup = false) {
|
|
7
8
|
const {
|
|
8
9
|
registerRef
|
|
9
10
|
} = useContext(FocusManagerContext);
|
|
10
11
|
const itemRef = useRef(null);
|
|
11
|
-
useEffect(() =>
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (hasPopup && fg('select-avoid-duplicated-registered-ref')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
registerRef(itemRef);
|
|
17
|
+
}, [registerRef, hasPopup]);
|
|
12
18
|
return itemRef;
|
|
13
19
|
}
|
|
14
20
|
export default useRegisterItemWithFocusManager;
|
|
@@ -38,7 +38,9 @@ var DropdownMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
38
38
|
returnFocusRef = _ref.returnFocusRef,
|
|
39
39
|
interactionName = _ref.interactionName,
|
|
40
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
-
|
|
41
|
+
// if the dropdown item has aria-haspopup, we won't register with focus manager
|
|
42
|
+
// since it is a nested trigger, we have registered inside dropdown-menu
|
|
43
|
+
var itemRef = useRegisterItemWithFocusManager(!!rest['aria-haspopup']);
|
|
42
44
|
var handleItemClick = useCallback(function (event) {
|
|
43
45
|
if (returnFocusRef !== null && returnFocusRef !== void 0 && returnFocusRef.current) {
|
|
44
46
|
returnFocusRef.current.focus();
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { FocusManagerContext } from '../components/focus-manager';
|
|
3
4
|
// This function is called whenever a MenuItem mounts.
|
|
4
5
|
// The refs stored in the context are used to programmatically
|
|
5
6
|
// control focus on a user navigates using the keyboard.
|
|
6
7
|
function useRegisterItemWithFocusManager() {
|
|
8
|
+
var hasPopup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
7
9
|
var _useContext = useContext(FocusManagerContext),
|
|
8
10
|
registerRef = _useContext.registerRef;
|
|
9
11
|
var itemRef = useRef(null);
|
|
10
12
|
useEffect(function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
if (hasPopup && fg('select-avoid-duplicated-registered-ref')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
registerRef(itemRef);
|
|
17
|
+
}, [registerRef, hasPopup]);
|
|
13
18
|
return itemRef;
|
|
14
19
|
}
|
|
15
20
|
export default useRegisterItemWithFocusManager;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
var _actionMap;
|
|
3
2
|
import { KEY_DOWN, KEY_END, KEY_HOME, KEY_TAB, KEY_UP } from '@atlaskit/ds-lib/keycodes';
|
|
4
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { PREFIX } from './use-generated-id';
|
|
6
|
-
var actionMap = (
|
|
5
|
+
var actionMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, KEY_DOWN, 'next'), KEY_UP, 'prev'), KEY_HOME, 'first'), KEY_END, 'last');
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* `currentFocusedIdx + 1` will not work if the next focusable element
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare function useRegisterItemWithFocusManager(): import("react").MutableRefObject<HTMLAnchorElement | HTMLButtonElement | null>;
|
|
2
|
+
declare function useRegisterItemWithFocusManager(hasPopup?: boolean): import("react").MutableRefObject<HTMLAnchorElement | HTMLButtonElement | null>;
|
|
3
3
|
export default useRegisterItemWithFocusManager;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -258,6 +258,10 @@ export interface DropdownItemProps {
|
|
|
258
258
|
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
259
259
|
*/
|
|
260
260
|
interactionName?: string;
|
|
261
|
+
/**
|
|
262
|
+
* An optional boolean value used to indicate if the dropdown item has popup or not.
|
|
263
|
+
*/
|
|
264
|
+
'aria-haspopup'?: boolean | 'dialog';
|
|
261
265
|
}
|
|
262
266
|
export interface DropdownItemCheckboxProps {
|
|
263
267
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare function useRegisterItemWithFocusManager(): import("react").MutableRefObject<HTMLAnchorElement | HTMLButtonElement | null>;
|
|
2
|
+
declare function useRegisterItemWithFocusManager(hasPopup?: boolean): import("react").MutableRefObject<HTMLAnchorElement | HTMLButtonElement | null>;
|
|
3
3
|
export default useRegisterItemWithFocusManager;
|
|
@@ -258,6 +258,10 @@ export interface DropdownItemProps {
|
|
|
258
258
|
* An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
|
|
259
259
|
*/
|
|
260
260
|
interactionName?: string;
|
|
261
|
+
/**
|
|
262
|
+
* An optional boolean value used to indicate if the dropdown item has popup or not.
|
|
263
|
+
*/
|
|
264
|
+
'aria-haspopup'?: boolean | 'dialog';
|
|
261
265
|
}
|
|
262
266
|
export interface DropdownItemCheckboxProps {
|
|
263
267
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "12.23.
|
|
3
|
+
"version": "12.23.3",
|
|
4
4
|
"description": "A dropdown menu displays a list of actions or options to a user.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/primitives": "^13.3.0",
|
|
37
37
|
"@atlaskit/spinner": "^16.3.0",
|
|
38
38
|
"@atlaskit/theme": "^14.0.0",
|
|
39
|
-
"@atlaskit/tokens": "^2.
|
|
39
|
+
"@atlaskit/tokens": "^2.5.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"@emotion/react": "^11.7.1",
|
|
42
42
|
"bind-event-listener": "^3.0.0"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@af/visual-regression": "*",
|
|
52
52
|
"@atlaskit/app-provider": "^1.4.0",
|
|
53
53
|
"@atlaskit/modal-dialog": "^12.18.0",
|
|
54
|
-
"@atlaskit/toggle": "^
|
|
54
|
+
"@atlaskit/toggle": "^14.0.0",
|
|
55
55
|
"@atlaskit/visual-regression": "*",
|
|
56
56
|
"@atlassian/feature-flags-test-utils": "*",
|
|
57
57
|
"@testing-library/dom": "^10.1.0",
|
|
@@ -83,6 +83,17 @@
|
|
|
83
83
|
},
|
|
84
84
|
"platform-icon-control-migration": {
|
|
85
85
|
"type": "boolean"
|
|
86
|
+
},
|
|
87
|
+
"select-avoid-duplicated-registered-ref": {
|
|
88
|
+
"type": "boolean"
|
|
89
|
+
},
|
|
90
|
+
"sibling-dropdown-close-issue": {
|
|
91
|
+
"type": "boolean",
|
|
92
|
+
"referenceOnly": true
|
|
93
|
+
},
|
|
94
|
+
"design-system-closed-all-when-click-outside": {
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"referenceOnly": true
|
|
86
97
|
}
|
|
87
98
|
},
|
|
88
99
|
"techstack": {
|