@atlaskit/dropdown-menu 14.1.2 → 14.1.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 +11 -0
- package/dist/cjs/dropdown-menu.js +12 -4
- package/dist/es2019/dropdown-menu.js +12 -4
- package/dist/esm/dropdown-menu.js +12 -4
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 14.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#148964](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/148964)
|
|
8
|
+
[`a07dc3da50fa9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a07dc3da50fa9) -
|
|
9
|
+
"We are testing keyboard focus improvement behind a feature flag. This change does not force focus
|
|
10
|
+
to return to the Dropdown trigger if another interactive element is clicked outside of the menu.
|
|
11
|
+
If this fix is successful it will be available in a later release."
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 14.1.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -185,10 +185,18 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
185
185
|
(_itemRef$current3 = itemRef.current) === null || _itemRef$current3 === void 0 || _itemRef$current3.focus();
|
|
186
186
|
});
|
|
187
187
|
} else if (triggerRef.current) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
var _event$target$closest2, _event$target2;
|
|
189
|
+
// Don't focus the trigger if the click was outside of the menu
|
|
190
|
+
var isClickOutsideMenu = (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && ((_event$target$closest2 = (_event$target2 = event.target).closest) === null || _event$target$closest2 === void 0 ? void 0 : _event$target$closest2.call(_event$target2, '[role="menu"]')) === null;
|
|
191
|
+
var shouldPreventFocus = isClickOutsideMenu && document.activeElement !== document.body &&
|
|
192
|
+
// except if clicking on the body
|
|
193
|
+
(0, _platformFeatureFlags.fg)('platform_design_system_team_dropdown_return_focus');
|
|
194
|
+
if (!shouldPreventFocus) {
|
|
195
|
+
requestAnimationFrame(function () {
|
|
196
|
+
var _triggerRef$current;
|
|
197
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 || _triggerRef$current.focus();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
192
200
|
}
|
|
193
201
|
var newValue = false;
|
|
194
202
|
setLocalIsOpen(newValue);
|
|
@@ -154,10 +154,18 @@ const DropdownMenu = ({
|
|
|
154
154
|
(_itemRef$current3 = itemRef.current) === null || _itemRef$current3 === void 0 ? void 0 : _itemRef$current3.focus();
|
|
155
155
|
});
|
|
156
156
|
} else if (triggerRef.current) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
var _event$target$closest2, _event$target2;
|
|
158
|
+
// Don't focus the trigger if the click was outside of the menu
|
|
159
|
+
const isClickOutsideMenu = (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && ((_event$target$closest2 = (_event$target2 = event.target).closest) === null || _event$target$closest2 === void 0 ? void 0 : _event$target$closest2.call(_event$target2, '[role="menu"]')) === null;
|
|
160
|
+
const shouldPreventFocus = isClickOutsideMenu && document.activeElement !== document.body &&
|
|
161
|
+
// except if clicking on the body
|
|
162
|
+
fg('platform_design_system_team_dropdown_return_focus');
|
|
163
|
+
if (!shouldPreventFocus) {
|
|
164
|
+
requestAnimationFrame(() => {
|
|
165
|
+
var _triggerRef$current;
|
|
166
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
161
169
|
}
|
|
162
170
|
const newValue = false;
|
|
163
171
|
setLocalIsOpen(newValue);
|
|
@@ -176,10 +176,18 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
176
176
|
(_itemRef$current3 = itemRef.current) === null || _itemRef$current3 === void 0 || _itemRef$current3.focus();
|
|
177
177
|
});
|
|
178
178
|
} else if (triggerRef.current) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
var _event$target$closest2, _event$target2;
|
|
180
|
+
// Don't focus the trigger if the click was outside of the menu
|
|
181
|
+
var isClickOutsideMenu = (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && ((_event$target$closest2 = (_event$target2 = event.target).closest) === null || _event$target$closest2 === void 0 ? void 0 : _event$target$closest2.call(_event$target2, '[role="menu"]')) === null;
|
|
182
|
+
var shouldPreventFocus = isClickOutsideMenu && document.activeElement !== document.body &&
|
|
183
|
+
// except if clicking on the body
|
|
184
|
+
fg('platform_design_system_team_dropdown_return_focus');
|
|
185
|
+
if (!shouldPreventFocus) {
|
|
186
|
+
requestAnimationFrame(function () {
|
|
187
|
+
var _triggerRef$current;
|
|
188
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 || _triggerRef$current.focus();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
183
191
|
}
|
|
184
192
|
var newValue = false;
|
|
185
193
|
setLocalIsOpen(newValue);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.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/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/menu": "^5.0.0",
|
|
34
34
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
35
35
|
"@atlaskit/popup": "^4.1.0",
|
|
36
|
-
"@atlaskit/primitives": "^14.
|
|
36
|
+
"@atlaskit/primitives": "^14.7.0",
|
|
37
37
|
"@atlaskit/spinner": "^18.0.0",
|
|
38
38
|
"@atlaskit/theme": "^18.0.0",
|
|
39
39
|
"@atlaskit/tokens": "^4.8.0",
|
|
@@ -101,6 +101,9 @@
|
|
|
101
101
|
},
|
|
102
102
|
"dropdown-menu-disabled-navigation-fix": {
|
|
103
103
|
"type": "boolean"
|
|
104
|
+
},
|
|
105
|
+
"platform_design_system_team_dropdown_return_focus": {
|
|
106
|
+
"type": "boolean"
|
|
104
107
|
}
|
|
105
108
|
},
|
|
106
109
|
"techstack": {
|