@atlaskit/dropdown-menu 12.24.0 → 12.25.0
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 +19 -0
- package/dist/cjs/dropdown-menu.js +1 -1
- package/dist/es2019/dropdown-menu.js +1 -1
- package/dist/esm/dropdown-menu.js +1 -1
- package/package.json +4 -7
- package/__perf__/default.tsx +0 -20
- package/__perf__/dropdown-menu.tsx +0 -186
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 12.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#105222](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105222)
|
|
8
|
+
[`f62a0d9ada12e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f62a0d9ada12e) -
|
|
9
|
+
Fixes a bug with the Dropdown Menu not returning focus to the returnFocusRef element, when
|
|
10
|
+
rendered in a portal. This change is no longer behind a feature flag.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 12.24.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 12.24.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -259,7 +259,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
259
259
|
shouldReturnFocus:
|
|
260
260
|
// If returnFocusRef is provided, we **don't** want to return focus to the trigger.
|
|
261
261
|
// Otherwise, Popup will focus on the dropdown trigger after the `returnFocusRef` element is focused.
|
|
262
|
-
|
|
262
|
+
returnFocusRef === undefined,
|
|
263
263
|
onClose: handleOnClose,
|
|
264
264
|
zIndex: zIndex,
|
|
265
265
|
placement: placement,
|
|
@@ -229,7 +229,7 @@ const DropdownMenu = ({
|
|
|
229
229
|
shouldReturnFocus:
|
|
230
230
|
// If returnFocusRef is provided, we **don't** want to return focus to the trigger.
|
|
231
231
|
// Otherwise, Popup will focus on the dropdown trigger after the `returnFocusRef` element is focused.
|
|
232
|
-
|
|
232
|
+
returnFocusRef === undefined,
|
|
233
233
|
onClose: handleOnClose,
|
|
234
234
|
zIndex: zIndex,
|
|
235
235
|
placement: placement,
|
|
@@ -250,7 +250,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
250
250
|
shouldReturnFocus:
|
|
251
251
|
// If returnFocusRef is provided, we **don't** want to return focus to the trigger.
|
|
252
252
|
// Otherwise, Popup will focus on the dropdown trigger after the `returnFocusRef` element is focused.
|
|
253
|
-
|
|
253
|
+
returnFocusRef === undefined,
|
|
254
254
|
onClose: handleOnClose,
|
|
255
255
|
zIndex: zIndex,
|
|
256
256
|
placement: placement,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.25.0",
|
|
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/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/button": "^20.3.0",
|
|
29
29
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
30
30
|
"@atlaskit/ds-lib": "^3.3.0",
|
|
31
|
-
"@atlaskit/icon": "^23.
|
|
31
|
+
"@atlaskit/icon": "^23.4.0",
|
|
32
32
|
"@atlaskit/layering": "^1.0.0",
|
|
33
33
|
"@atlaskit/menu": "^2.13.0",
|
|
34
34
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
@@ -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": "^3.2.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"@emotion/react": "^11.7.1",
|
|
42
42
|
"bind-event-listener": "^3.0.0"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@af/accessibility-testing": "*",
|
|
50
50
|
"@af/integration-testing": "*",
|
|
51
51
|
"@af/visual-regression": "*",
|
|
52
|
-
"@atlaskit/app-provider": "^1.
|
|
52
|
+
"@atlaskit/app-provider": "^1.6.0",
|
|
53
53
|
"@atlaskit/modal-dialog": "^12.19.0",
|
|
54
54
|
"@atlaskit/toggle": "^14.0.0",
|
|
55
55
|
"@atlaskit/visual-regression": "*",
|
|
@@ -98,9 +98,6 @@
|
|
|
98
98
|
"fix-dropdown-close-outside-iframe": {
|
|
99
99
|
"type": "boolean",
|
|
100
100
|
"referenceOnly": true
|
|
101
|
-
},
|
|
102
|
-
"platform_dst_dropdown_return_focus_fix": {
|
|
103
|
-
"type": "boolean"
|
|
104
101
|
}
|
|
105
102
|
},
|
|
106
103
|
"techstack": {
|
package/__perf__/default.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '../src';
|
|
4
|
-
|
|
5
|
-
const DropdownMenuDefaultExample = () => (
|
|
6
|
-
<DropdownMenu trigger="Cities in Australia">
|
|
7
|
-
<DropdownItemGroup>
|
|
8
|
-
<DropdownItem>Sydney</DropdownItem>
|
|
9
|
-
<DropdownItem>Melbourne</DropdownItem>
|
|
10
|
-
<DropdownItem>Adelaide</DropdownItem>
|
|
11
|
-
<DropdownItem>Perth</DropdownItem>
|
|
12
|
-
<DropdownItem>Brisbane</DropdownItem>
|
|
13
|
-
<DropdownItem>Canberra</DropdownItem>
|
|
14
|
-
<DropdownItem>Hobart</DropdownItem>
|
|
15
|
-
<DropdownItem>Darwin</DropdownItem>
|
|
16
|
-
</DropdownItemGroup>
|
|
17
|
-
</DropdownMenu>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export default DropdownMenuDefaultExample;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { fireEvent, screen, waitFor } from '@testing-library/dom';
|
|
4
|
-
import type { InteractionTaskArgs, PublicInteractionTask } from 'storybook-addon-performance';
|
|
5
|
-
import invariant from 'tiny-invariant';
|
|
6
|
-
|
|
7
|
-
import DropdownMenu, {
|
|
8
|
-
DropdownItem,
|
|
9
|
-
DropdownItemCheckbox,
|
|
10
|
-
DropdownItemCheckboxGroup,
|
|
11
|
-
DropdownItemGroup,
|
|
12
|
-
DropdownItemRadio,
|
|
13
|
-
DropdownItemRadioGroup,
|
|
14
|
-
} from '../src';
|
|
15
|
-
|
|
16
|
-
const DropdownMenuPerformance = () => (
|
|
17
|
-
<DropdownMenu trigger="Page actions" testId="dropdown-menu">
|
|
18
|
-
<DropdownItemGroup>
|
|
19
|
-
<DropdownItem>Edit</DropdownItem>
|
|
20
|
-
<DropdownItem>Copy</DropdownItem>
|
|
21
|
-
<DropdownItem>Delete</DropdownItem>
|
|
22
|
-
</DropdownItemGroup>
|
|
23
|
-
<DropdownItemCheckboxGroup id="flags" title="Flags">
|
|
24
|
-
<DropdownItemCheckbox id="tokens">Tokens</DropdownItemCheckbox>
|
|
25
|
-
<DropdownItemCheckbox id="dark-mode">Dark mode</DropdownItemCheckbox>
|
|
26
|
-
</DropdownItemCheckboxGroup>
|
|
27
|
-
<DropdownItemRadioGroup id="font-size" title="Font size">
|
|
28
|
-
<DropdownItemRadio id="smaller">Smaller</DropdownItemRadio>
|
|
29
|
-
<DropdownItemRadio id="default" defaultSelected>
|
|
30
|
-
Default
|
|
31
|
-
</DropdownItemRadio>
|
|
32
|
-
<DropdownItemRadio id="larger">Larger</DropdownItemRadio>
|
|
33
|
-
</DropdownItemRadioGroup>
|
|
34
|
-
</DropdownMenu>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const getTrigger = (container: HTMLElement): HTMLElement => {
|
|
38
|
-
const trigger: HTMLElement | null = container.querySelector(
|
|
39
|
-
'[data-testid="dropdown-menu--trigger"]',
|
|
40
|
-
);
|
|
41
|
-
if (trigger === null) {
|
|
42
|
-
throw new Error('Could not find the dropdown menu trigger');
|
|
43
|
-
}
|
|
44
|
-
return trigger;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const interactionTasks: PublicInteractionTask[] = [
|
|
48
|
-
{
|
|
49
|
-
name: 'Display dropdown',
|
|
50
|
-
description: 'Click to open the dropdown menu',
|
|
51
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
52
|
-
const trigger = getTrigger(container);
|
|
53
|
-
|
|
54
|
-
await controls.time(async () => {
|
|
55
|
-
fireEvent.click(trigger);
|
|
56
|
-
await screen.findByText('Edit');
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'Hide dropdown (trigger)',
|
|
62
|
-
description: 'Click the trigger to hide the dropdown menu',
|
|
63
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
64
|
-
const trigger = getTrigger(container);
|
|
65
|
-
fireEvent.click(trigger);
|
|
66
|
-
|
|
67
|
-
await screen.findByText('Edit');
|
|
68
|
-
await controls.time(async () => {
|
|
69
|
-
fireEvent.click(trigger);
|
|
70
|
-
await waitFor(() => invariant(screen.queryByText('Edit') === null));
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'Hide dropdown (escape)',
|
|
76
|
-
description: 'Press escape to hide the dropdown menu',
|
|
77
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
78
|
-
const trigger = getTrigger(container);
|
|
79
|
-
fireEvent.click(trigger);
|
|
80
|
-
|
|
81
|
-
await screen.findByText('Edit');
|
|
82
|
-
await controls.time(async () => {
|
|
83
|
-
fireEvent.keyDown(container, { key: 'Escape', code: 'Escape' });
|
|
84
|
-
await waitFor(() => invariant(screen.queryByText('Edit') === null));
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'Hide dropdown (outside click)',
|
|
90
|
-
description: 'Click outside to hide the dropdown menu',
|
|
91
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
92
|
-
const trigger = getTrigger(container);
|
|
93
|
-
fireEvent.click(trigger);
|
|
94
|
-
|
|
95
|
-
await screen.findByText('Edit');
|
|
96
|
-
await controls.time(async () => {
|
|
97
|
-
fireEvent.click(container);
|
|
98
|
-
await waitFor(() => invariant(screen.queryByText('Edit') === null));
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'Select item',
|
|
104
|
-
description: 'Click menu item to select it',
|
|
105
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
106
|
-
const trigger = getTrigger(container);
|
|
107
|
-
fireEvent.click(trigger);
|
|
108
|
-
|
|
109
|
-
const label = await screen.findByText('Edit');
|
|
110
|
-
await controls.time(async () => {
|
|
111
|
-
label.click();
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
/**
|
|
117
|
-
* NOTE:
|
|
118
|
-
* This test has an unhandled error on CI, but runs fine locally.
|
|
119
|
-
* It doesn't stop the pipeline, but its results aren't reported.
|
|
120
|
-
*/
|
|
121
|
-
name: 'Select checkbox',
|
|
122
|
-
description: 'Click a checkbox menu item to select it',
|
|
123
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
124
|
-
const trigger = getTrigger(container);
|
|
125
|
-
fireEvent.click(trigger);
|
|
126
|
-
|
|
127
|
-
const label = await screen.findByText('Tokens');
|
|
128
|
-
const checkbox: HTMLElement | null = label.closest('[role="checkbox"]');
|
|
129
|
-
if (checkbox === null) {
|
|
130
|
-
throw new Error('Could not find the checkbox');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
await controls.time(async () => {
|
|
134
|
-
checkbox.click();
|
|
135
|
-
await waitFor(
|
|
136
|
-
() => {
|
|
137
|
-
const ariaChecked = checkbox.getAttribute('aria-checked');
|
|
138
|
-
invariant(ariaChecked === 'true', `Checkbox should be checked (is "${ariaChecked}")`);
|
|
139
|
-
},
|
|
140
|
-
{ timeout: 5000 },
|
|
141
|
-
);
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
/**
|
|
147
|
-
* NOTE:
|
|
148
|
-
* This test has an unhandled error on CI, but runs fine locally.
|
|
149
|
-
* It doesn't stop the pipeline, but its results aren't reported.
|
|
150
|
-
*/
|
|
151
|
-
name: 'Select radio',
|
|
152
|
-
description: 'Click a radio menu item to select it',
|
|
153
|
-
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
154
|
-
const trigger = getTrigger(container);
|
|
155
|
-
fireEvent.click(trigger);
|
|
156
|
-
|
|
157
|
-
const label = await screen.findByText('Smaller');
|
|
158
|
-
const radio: HTMLElement | null = label.closest('[role="radio"]');
|
|
159
|
-
if (radio === null) {
|
|
160
|
-
throw new Error('Could not find the radio');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
await controls.time(async () => {
|
|
164
|
-
radio.click();
|
|
165
|
-
await waitFor(
|
|
166
|
-
() => {
|
|
167
|
-
const ariaChecked = radio.getAttribute('aria-checked');
|
|
168
|
-
invariant(ariaChecked === 'true', `Radio should be checked (is "${ariaChecked}")`);
|
|
169
|
-
},
|
|
170
|
-
{ timeout: 5000 },
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
DropdownMenuPerformance.story = {
|
|
178
|
-
name: 'Dropdown menu',
|
|
179
|
-
parameters: {
|
|
180
|
-
performance: {
|
|
181
|
-
interactions: interactionTasks,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export default DropdownMenuPerformance;
|