@atlaskit/dropdown-menu 12.1.3 → 12.1.5
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 +12 -0
- package/dist/cjs/dropdown-menu.js +11 -2
- package/dist/es2019/dropdown-menu.js +10 -1
- package/dist/esm/dropdown-menu.js +10 -1
- package/dist/types/dropdown-menu.d.ts +2 -0
- package/dist/types/types.d.ts +8 -5
- package/dist/types-ts4.5/dropdown-menu.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +8 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 12.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#42645](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42645) [`df1c4868d29`](https://bitbucket.org/atlassian/atlassian-frontend/commits/df1c4868d29) - Fix keyboard access for custom trigger.
|
|
8
|
+
|
|
9
|
+
## 12.1.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#41898](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41898) [`b3c84e42159`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3c84e42159) - Fix loss of autofocus when opening with Enter and Space keys.
|
|
14
|
+
|
|
3
15
|
## 12.1.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.KEY_SPACE = exports.KEY_ENTER = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
@@ -42,6 +42,8 @@ var opposites = {
|
|
|
42
42
|
auto: 'auto',
|
|
43
43
|
end: 'start'
|
|
44
44
|
};
|
|
45
|
+
var KEY_SPACE = exports.KEY_SPACE = ' ';
|
|
46
|
+
var KEY_ENTER = exports.KEY_ENTER = 'Enter';
|
|
45
47
|
var getFallbackPlacements = function getFallbackPlacements(placement) {
|
|
46
48
|
var placementPieces = placement.split('-');
|
|
47
49
|
var mainAxis = placementPieces[0];
|
|
@@ -116,13 +118,17 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
116
118
|
var newValue = !isLocalOpen;
|
|
117
119
|
var clientX = event.clientX,
|
|
118
120
|
clientY = event.clientY,
|
|
119
|
-
type = event.type
|
|
121
|
+
type = event.type,
|
|
122
|
+
detail = event.detail;
|
|
120
123
|
if (type === 'keydown') {
|
|
121
124
|
setTriggeredUsingKeyboard(true);
|
|
122
125
|
} else if (clientX === 0 || clientY === 0) {
|
|
123
126
|
// Hitting enter/space is registered as a click
|
|
124
127
|
// with both clientX and clientY === 0
|
|
125
128
|
setTriggeredUsingKeyboard(true);
|
|
129
|
+
} else if (detail === 0) {
|
|
130
|
+
// Fix for Safari. clientX and clientY !== 0 in Safari
|
|
131
|
+
setTriggeredUsingKeyboard(true);
|
|
126
132
|
}
|
|
127
133
|
setLocalIsOpen(newValue);
|
|
128
134
|
onOpenChange({
|
|
@@ -167,6 +173,9 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
167
173
|
// prevent page scroll
|
|
168
174
|
e.preventDefault();
|
|
169
175
|
handleTriggerClicked(e);
|
|
176
|
+
} else if ((e.key === KEY_SPACE || e.key === KEY_ENTER) && e.detail === 0) {
|
|
177
|
+
// This allows us to focus on the first element if the dropdown was triggered by a custom trigger with a custom onClick
|
|
178
|
+
setTriggeredUsingKeyboard(true);
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
181
|
});
|
|
@@ -27,6 +27,8 @@ const opposites = {
|
|
|
27
27
|
auto: 'auto',
|
|
28
28
|
end: 'start'
|
|
29
29
|
};
|
|
30
|
+
export const KEY_SPACE = ' ';
|
|
31
|
+
export const KEY_ENTER = 'Enter';
|
|
30
32
|
const getFallbackPlacements = placement => {
|
|
31
33
|
const placementPieces = placement.split('-');
|
|
32
34
|
const mainAxis = placementPieces[0];
|
|
@@ -85,7 +87,8 @@ const DropdownMenu = ({
|
|
|
85
87
|
const {
|
|
86
88
|
clientX,
|
|
87
89
|
clientY,
|
|
88
|
-
type
|
|
90
|
+
type,
|
|
91
|
+
detail
|
|
89
92
|
} = event;
|
|
90
93
|
if (type === 'keydown') {
|
|
91
94
|
setTriggeredUsingKeyboard(true);
|
|
@@ -93,6 +96,9 @@ const DropdownMenu = ({
|
|
|
93
96
|
// Hitting enter/space is registered as a click
|
|
94
97
|
// with both clientX and clientY === 0
|
|
95
98
|
setTriggeredUsingKeyboard(true);
|
|
99
|
+
} else if (detail === 0) {
|
|
100
|
+
// Fix for Safari. clientX and clientY !== 0 in Safari
|
|
101
|
+
setTriggeredUsingKeyboard(true);
|
|
96
102
|
}
|
|
97
103
|
setLocalIsOpen(newValue);
|
|
98
104
|
onOpenChange({
|
|
@@ -138,6 +144,9 @@ const DropdownMenu = ({
|
|
|
138
144
|
// prevent page scroll
|
|
139
145
|
e.preventDefault();
|
|
140
146
|
handleTriggerClicked(e);
|
|
147
|
+
} else if ((e.key === KEY_SPACE || e.key === KEY_ENTER) && e.detail === 0) {
|
|
148
|
+
// This allows us to focus on the first element if the dropdown was triggered by a custom trigger with a custom onClick
|
|
149
|
+
setTriggeredUsingKeyboard(true);
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
});
|
|
@@ -33,6 +33,8 @@ var opposites = {
|
|
|
33
33
|
auto: 'auto',
|
|
34
34
|
end: 'start'
|
|
35
35
|
};
|
|
36
|
+
export var KEY_SPACE = ' ';
|
|
37
|
+
export var KEY_ENTER = 'Enter';
|
|
36
38
|
var getFallbackPlacements = function getFallbackPlacements(placement) {
|
|
37
39
|
var placementPieces = placement.split('-');
|
|
38
40
|
var mainAxis = placementPieces[0];
|
|
@@ -107,13 +109,17 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
107
109
|
var newValue = !isLocalOpen;
|
|
108
110
|
var clientX = event.clientX,
|
|
109
111
|
clientY = event.clientY,
|
|
110
|
-
type = event.type
|
|
112
|
+
type = event.type,
|
|
113
|
+
detail = event.detail;
|
|
111
114
|
if (type === 'keydown') {
|
|
112
115
|
setTriggeredUsingKeyboard(true);
|
|
113
116
|
} else if (clientX === 0 || clientY === 0) {
|
|
114
117
|
// Hitting enter/space is registered as a click
|
|
115
118
|
// with both clientX and clientY === 0
|
|
116
119
|
setTriggeredUsingKeyboard(true);
|
|
120
|
+
} else if (detail === 0) {
|
|
121
|
+
// Fix for Safari. clientX and clientY !== 0 in Safari
|
|
122
|
+
setTriggeredUsingKeyboard(true);
|
|
117
123
|
}
|
|
118
124
|
setLocalIsOpen(newValue);
|
|
119
125
|
onOpenChange({
|
|
@@ -158,6 +164,9 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
158
164
|
// prevent page scroll
|
|
159
165
|
e.preventDefault();
|
|
160
166
|
handleTriggerClicked(e);
|
|
167
|
+
} else if ((e.key === KEY_SPACE || e.key === KEY_ENTER) && e.detail === 0) {
|
|
168
|
+
// This allows us to focus on the first element if the dropdown was triggered by a custom trigger with a custom onClick
|
|
169
|
+
setTriggeredUsingKeyboard(true);
|
|
161
170
|
}
|
|
162
171
|
}
|
|
163
172
|
});
|
package/dist/types/types.d.ts
CHANGED
|
@@ -55,13 +55,13 @@ export interface DropdownMenuGroupProps extends SectionProps {
|
|
|
55
55
|
export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
|
|
56
56
|
/**
|
|
57
57
|
* Controls the appearance of the menu.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* The default menu will scroll after its height exceeds the pre-defined amount.
|
|
59
|
+
* The tall menu will not scroll until the height exceeds the height of the viewport.
|
|
60
60
|
*/
|
|
61
61
|
appearance?: 'default' | 'tall';
|
|
62
62
|
/**
|
|
63
63
|
* Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
|
|
64
|
-
* which traps the focus within the menu.
|
|
64
|
+
* which traps the focus within the menu. The first item gets focus automatically
|
|
65
65
|
* if the menu is triggered using the keyboard.
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
@@ -103,8 +103,11 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
103
103
|
*/
|
|
104
104
|
spacing?: Extract<MenuGroupProps['spacing'], 'cozy' | 'compact'>;
|
|
105
105
|
/**
|
|
106
|
-
* Content
|
|
107
|
-
* to
|
|
106
|
+
* Content that triggers the dropdown menu to open and close. Use with
|
|
107
|
+
* `triggerType` to get a button trigger. To customize the trigger element,
|
|
108
|
+
* provide a function to this prop. You can find
|
|
109
|
+
* [examples for custom triggers](components/dropdown-menu/examples#custom-triggers)
|
|
110
|
+
* in our documentation.
|
|
108
111
|
*/
|
|
109
112
|
trigger?: string | ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement);
|
|
110
113
|
/**
|
|
@@ -55,13 +55,13 @@ export interface DropdownMenuGroupProps extends SectionProps {
|
|
|
55
55
|
export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
|
|
56
56
|
/**
|
|
57
57
|
* Controls the appearance of the menu.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* The default menu will scroll after its height exceeds the pre-defined amount.
|
|
59
|
+
* The tall menu will not scroll until the height exceeds the height of the viewport.
|
|
60
60
|
*/
|
|
61
61
|
appearance?: 'default' | 'tall';
|
|
62
62
|
/**
|
|
63
63
|
* Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
|
|
64
|
-
* which traps the focus within the menu.
|
|
64
|
+
* which traps the focus within the menu. The first item gets focus automatically
|
|
65
65
|
* if the menu is triggered using the keyboard.
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
@@ -103,8 +103,11 @@ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElem
|
|
|
103
103
|
*/
|
|
104
104
|
spacing?: Extract<MenuGroupProps['spacing'], 'cozy' | 'compact'>;
|
|
105
105
|
/**
|
|
106
|
-
* Content
|
|
107
|
-
* to
|
|
106
|
+
* Content that triggers the dropdown menu to open and close. Use with
|
|
107
|
+
* `triggerType` to get a button trigger. To customize the trigger element,
|
|
108
|
+
* provide a function to this prop. You can find
|
|
109
|
+
* [examples for custom triggers](components/dropdown-menu/examples#custom-triggers)
|
|
110
|
+
* in our documentation.
|
|
108
111
|
*/
|
|
109
112
|
trigger?: string | ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement);
|
|
110
113
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.5",
|
|
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/"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@atlaskit/button": "^16.
|
|
26
|
+
"@atlaskit/button": "^16.13.0",
|
|
27
27
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
28
28
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
29
29
|
"@atlaskit/icon": "^21.12.0",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@atlaskit/menu": "^2.1.0",
|
|
32
32
|
"@atlaskit/platform-feature-flags": "^0.2.2",
|
|
33
33
|
"@atlaskit/popup": "^1.11.0",
|
|
34
|
-
"@atlaskit/primitives": "^1.
|
|
34
|
+
"@atlaskit/primitives": "^1.9.0",
|
|
35
35
|
"@atlaskit/spinner": "^15.6.0",
|
|
36
36
|
"@atlaskit/theme": "^12.6.0",
|
|
37
|
-
"@atlaskit/tokens": "^1.
|
|
37
|
+
"@atlaskit/tokens": "^1.28.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"@emotion/react": "^11.7.1",
|
|
40
40
|
"bind-event-listener": "^2.1.1"
|