@instructure/ui-menu 10.16.1-snapshot-0 → 10.16.1
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 +1 -1
- package/es/Menu/MenuItem/__new-tests__/MenuItem.test.js +53 -35
- package/es/Menu/MenuItem/index.js +26 -17
- package/es/Menu/MenuItemGroup/__new-tests__/MenuItemGroup.test.js +87 -43
- package/es/Menu/MenuItemGroup/index.js +16 -12
- package/es/Menu/MenuItemSeparator/index.js +5 -4
- package/es/Menu/__new-tests__/Menu.test.js +204 -107
- package/es/Menu/index.js +28 -23
- package/lib/Menu/MenuItem/__new-tests__/MenuItem.test.js +66 -49
- package/lib/Menu/MenuItem/index.js +24 -17
- package/lib/Menu/MenuItemGroup/__new-tests__/MenuItemGroup.test.js +99 -56
- package/lib/Menu/MenuItemGroup/index.js +15 -12
- package/lib/Menu/MenuItemSeparator/index.js +4 -3
- package/lib/Menu/__new-tests__/Menu.test.js +216 -121
- package/lib/Menu/index.js +26 -23
- package/package.json +19 -19
- package/src/Menu/MenuItem/__new-tests__/MenuItem.test.tsx +0 -1
- package/src/Menu/MenuItem/index.tsx +3 -3
- package/src/Menu/MenuItemGroup/__new-tests__/MenuItemGroup.test.tsx +0 -1
- package/src/Menu/MenuItemGroup/index.tsx +4 -5
- package/src/Menu/MenuItemSeparator/index.tsx +1 -2
- package/src/Menu/__new-tests__/Menu.test.tsx +1 -1
- package/src/Menu/index.tsx +7 -7
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Menu/MenuItem/__new-tests__/MenuItem.test.d.ts.map +1 -1
- package/types/Menu/MenuItem/index.d.ts +5 -7
- package/types/Menu/MenuItem/index.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/__new-tests__/MenuItemGroup.test.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/index.d.ts +5 -7
- package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
- package/types/Menu/MenuItemSeparator/index.d.ts +1 -3
- package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
- package/types/Menu/index.d.ts +8 -10
- package/types/Menu/index.d.ts.map +1 -1
|
@@ -22,13 +22,14 @@ var _Menu, _Menu2, _Menu3, _Menu4, _MenuItem, _MenuItem2, _MenuItem3, _Menu5, _b
|
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
27
27
|
import { vi } from 'vitest';
|
|
28
28
|
import { userEvent } from '@testing-library/user-event';
|
|
29
29
|
import '@testing-library/jest-dom';
|
|
30
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
31
|
import { Menu, MenuItem, MenuItemSeparator } from '../index';
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
32
33
|
describe('<Menu />', () => {
|
|
33
34
|
let consoleWarningMock;
|
|
34
35
|
let consoleErrorMock;
|
|
@@ -43,51 +44,71 @@ describe('<Menu />', () => {
|
|
|
43
44
|
});
|
|
44
45
|
describe('without a trigger', () => {
|
|
45
46
|
it('should render', () => {
|
|
46
|
-
render(_Menu || (_Menu =
|
|
47
|
-
label: "Menu-label-text"
|
|
48
|
-
|
|
47
|
+
render(_Menu || (_Menu = _jsx(Menu, {
|
|
48
|
+
label: "Menu-label-text",
|
|
49
|
+
children: _jsx(MenuItem, {
|
|
50
|
+
children: "Menu Item Text"
|
|
51
|
+
})
|
|
52
|
+
})));
|
|
49
53
|
const menu = screen.getByRole('menu');
|
|
50
54
|
expect(menu).toBeInTheDocument();
|
|
51
55
|
expect(menu).toHaveTextContent('Menu Item Text');
|
|
52
56
|
expect(menu).toHaveAttribute('aria-label', 'Menu-label-text');
|
|
53
57
|
});
|
|
54
58
|
it('should meet a11y standards', async () => {
|
|
55
|
-
const _render = render(_Menu2 || (_Menu2 =
|
|
56
|
-
label: "Menu-label-text"
|
|
57
|
-
|
|
59
|
+
const _render = render(_Menu2 || (_Menu2 = _jsx(Menu, {
|
|
60
|
+
label: "Menu-label-text",
|
|
61
|
+
children: _jsx(MenuItem, {
|
|
62
|
+
children: "Menu Item Text"
|
|
63
|
+
})
|
|
64
|
+
}))),
|
|
58
65
|
container = _render.container;
|
|
59
66
|
const axeCheck = await runAxeCheck(container);
|
|
60
67
|
expect(axeCheck).toBe(true);
|
|
61
68
|
});
|
|
62
69
|
it('should meet standards when menu is closed', async () => {
|
|
63
|
-
const _render2 = render(_Menu3 || (_Menu3 =
|
|
64
|
-
trigger:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
const _render2 = render(_Menu3 || (_Menu3 = _jsxs(Menu, {
|
|
71
|
+
trigger: _jsx("button", {
|
|
72
|
+
children: "More"
|
|
73
|
+
}),
|
|
74
|
+
children: [_jsx(MenuItem, {
|
|
75
|
+
children: "Learning Mastery"
|
|
76
|
+
}), _jsx(MenuItem, {
|
|
77
|
+
disabled: true,
|
|
78
|
+
children: "Gradebook"
|
|
79
|
+
})]
|
|
80
|
+
}))),
|
|
68
81
|
container = _render2.container;
|
|
69
82
|
const axeCheck = await runAxeCheck(container);
|
|
70
83
|
expect(axeCheck).toBe(true);
|
|
71
84
|
});
|
|
72
85
|
it('should meet standards when menu is open', async () => {
|
|
73
|
-
const _render3 = render(_Menu4 || (_Menu4 =
|
|
74
|
-
trigger:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
const _render3 = render(_Menu4 || (_Menu4 = _jsxs(Menu, {
|
|
87
|
+
trigger: _jsx("button", {
|
|
88
|
+
children: "More"
|
|
89
|
+
}),
|
|
90
|
+
defaultShow: true,
|
|
91
|
+
children: [_jsx(MenuItem, {
|
|
92
|
+
children: "Learning Mastery"
|
|
93
|
+
}), _jsx(MenuItem, {
|
|
94
|
+
disabled: true,
|
|
95
|
+
children: "Gradebook"
|
|
96
|
+
})]
|
|
97
|
+
}))),
|
|
79
98
|
container = _render3.container;
|
|
80
99
|
const axeCheck = await runAxeCheck(container);
|
|
81
100
|
expect(axeCheck).toBe(true);
|
|
82
101
|
});
|
|
83
102
|
it('should call onSelect when menu item is selected', async () => {
|
|
84
103
|
const onSelect = vi.fn();
|
|
85
|
-
const _render4 = render(
|
|
104
|
+
const _render4 = render(_jsx(Menu, {
|
|
86
105
|
label: "Settings",
|
|
87
|
-
onSelect: onSelect
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
onSelect: onSelect,
|
|
107
|
+
children: _MenuItem || (_MenuItem = _jsx(MenuItem, {
|
|
108
|
+
value: "Test",
|
|
109
|
+
children: "Test Item"
|
|
110
|
+
}))
|
|
111
|
+
})),
|
|
91
112
|
getByText = _render4.getByText;
|
|
92
113
|
const item = getByText('Test Item');
|
|
93
114
|
await userEvent.click(item);
|
|
@@ -96,13 +117,15 @@ describe('<Menu />', () => {
|
|
|
96
117
|
});
|
|
97
118
|
it('should not call onSelect when disabled', () => {
|
|
98
119
|
const onSelect = vi.fn();
|
|
99
|
-
const _render5 = render(
|
|
120
|
+
const _render5 = render(_jsx(Menu, {
|
|
100
121
|
label: "Settings",
|
|
101
122
|
onSelect: onSelect,
|
|
102
|
-
disabled: true
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
disabled: true,
|
|
124
|
+
children: _MenuItem2 || (_MenuItem2 = _jsx(MenuItem, {
|
|
125
|
+
value: "Account",
|
|
126
|
+
children: "Account"
|
|
127
|
+
}))
|
|
128
|
+
})),
|
|
106
129
|
getByText = _render5.getByText;
|
|
107
130
|
const itemText = getByText('Account');
|
|
108
131
|
const menu = screen.getByRole('menu');
|
|
@@ -113,22 +136,26 @@ describe('<Menu />', () => {
|
|
|
113
136
|
});
|
|
114
137
|
it('should provide a menu ref', () => {
|
|
115
138
|
const menuRef = vi.fn();
|
|
116
|
-
render(
|
|
139
|
+
render(_jsx(Menu, {
|
|
117
140
|
label: "Settings",
|
|
118
|
-
menuRef: menuRef
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
141
|
+
menuRef: menuRef,
|
|
142
|
+
children: _MenuItem3 || (_MenuItem3 = _jsx(MenuItem, {
|
|
143
|
+
value: "Account",
|
|
144
|
+
children: "Account"
|
|
145
|
+
}))
|
|
146
|
+
}));
|
|
122
147
|
const menu = screen.getByRole('menu');
|
|
123
148
|
expect(menuRef).toHaveBeenLastCalledWith(menu);
|
|
124
149
|
});
|
|
125
150
|
it('should set aria attributes properly', () => {
|
|
126
|
-
render(_Menu5 || (_Menu5 =
|
|
151
|
+
render(_Menu5 || (_Menu5 = _jsx(Menu, {
|
|
127
152
|
disabled: true,
|
|
128
|
-
label: "Settings"
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
153
|
+
label: "Settings",
|
|
154
|
+
children: _jsx(MenuItem, {
|
|
155
|
+
value: "Account",
|
|
156
|
+
children: "Account"
|
|
157
|
+
})
|
|
158
|
+
})));
|
|
132
159
|
const menu = screen.getByRole('menu');
|
|
133
160
|
expect(menu).toHaveAttribute('aria-disabled', 'true');
|
|
134
161
|
expect(menu).toHaveAttribute('aria-label', 'Settings');
|
|
@@ -138,30 +165,46 @@ describe('<Menu />', () => {
|
|
|
138
165
|
it('should render into a mountNode', () => {
|
|
139
166
|
const mountNode = document.createElement('div');
|
|
140
167
|
document.body.appendChild(mountNode);
|
|
141
|
-
render(
|
|
168
|
+
render(_jsx(Menu, {
|
|
142
169
|
defaultShow: true,
|
|
143
170
|
mountNode: mountNode,
|
|
144
171
|
label: "Settings",
|
|
145
|
-
trigger: _button || (_button =
|
|
146
|
-
|
|
172
|
+
trigger: _button || (_button = _jsx("button", {
|
|
173
|
+
children: "Settings"
|
|
174
|
+
})),
|
|
175
|
+
children: _MenuItem4 || (_MenuItem4 = _jsx(MenuItem, {
|
|
176
|
+
children: "Account"
|
|
177
|
+
}))
|
|
178
|
+
}));
|
|
147
179
|
expect(mountNode).toHaveTextContent('Account');
|
|
148
180
|
document.body.removeChild(mountNode);
|
|
149
181
|
});
|
|
150
182
|
it('should set aria attributes properly', () => {
|
|
151
|
-
render(_Menu6 || (_Menu6 =
|
|
152
|
-
trigger:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
render(_Menu6 || (_Menu6 = _jsxs(Menu, {
|
|
184
|
+
trigger: _jsx("button", {
|
|
185
|
+
children: "Settings"
|
|
186
|
+
}),
|
|
187
|
+
defaultShow: true,
|
|
188
|
+
children: [_jsx(MenuItem, {
|
|
189
|
+
children: "Learning Mastery"
|
|
190
|
+
}), _jsx(MenuItem, {
|
|
191
|
+
disabled: true,
|
|
192
|
+
children: "Gradebook"
|
|
193
|
+
}), _jsx(MenuItem, {
|
|
194
|
+
type: "radio",
|
|
195
|
+
defaultChecked: true,
|
|
196
|
+
children: "Default (Grid view)"
|
|
197
|
+
}), _jsx(MenuItem, {
|
|
198
|
+
type: "radio",
|
|
199
|
+
children: "Individual (List view)"
|
|
200
|
+
}), _jsx(MenuItem, {
|
|
201
|
+
type: "checkbox",
|
|
202
|
+
defaultChecked: true,
|
|
203
|
+
children: "Include Anchor Standards"
|
|
204
|
+
}), _jsx(MenuItemSeparator, {}), _jsx(MenuItem, {
|
|
205
|
+
children: "Open grading history..."
|
|
206
|
+
})]
|
|
207
|
+
})));
|
|
165
208
|
const menu = screen.getByRole('menu');
|
|
166
209
|
const trigger = screen.getByRole('button', {
|
|
167
210
|
name: 'Settings'
|
|
@@ -171,12 +214,18 @@ describe('<Menu />', () => {
|
|
|
171
214
|
});
|
|
172
215
|
it('should call onFocus on focus', () => {
|
|
173
216
|
const onFocus = vi.fn();
|
|
174
|
-
const _render6 = render(
|
|
175
|
-
trigger: _button2 || (_button2 =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
217
|
+
const _render6 = render(_jsxs(Menu, {
|
|
218
|
+
trigger: _button2 || (_button2 = _jsx("button", {
|
|
219
|
+
children: "More"
|
|
220
|
+
})),
|
|
221
|
+
onFocus: onFocus,
|
|
222
|
+
children: [_MenuItem5 || (_MenuItem5 = _jsx(MenuItem, {
|
|
223
|
+
children: "Learning Mastery"
|
|
224
|
+
})), _MenuItem6 || (_MenuItem6 = _jsx(MenuItem, {
|
|
225
|
+
disabled: true,
|
|
226
|
+
children: "Gradebook"
|
|
227
|
+
}))]
|
|
228
|
+
})),
|
|
180
229
|
getByRole = _render6.getByRole;
|
|
181
230
|
const triggerButton = getByRole('button', {
|
|
182
231
|
name: 'More'
|
|
@@ -185,13 +234,19 @@ describe('<Menu />', () => {
|
|
|
185
234
|
expect(onFocus).toHaveBeenCalled();
|
|
186
235
|
});
|
|
187
236
|
it('should render when show and onToggle props are set', () => {
|
|
188
|
-
const _render7 = render(
|
|
189
|
-
trigger: _button3 || (_button3 =
|
|
237
|
+
const _render7 = render(_jsxs(Menu, {
|
|
238
|
+
trigger: _button3 || (_button3 = _jsx("button", {
|
|
239
|
+
children: "More"
|
|
240
|
+
})),
|
|
190
241
|
show: true,
|
|
191
|
-
onToggle: () => {}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
242
|
+
onToggle: () => {},
|
|
243
|
+
children: [_MenuItem7 || (_MenuItem7 = _jsx(MenuItem, {
|
|
244
|
+
children: "Test1"
|
|
245
|
+
})), _MenuItem8 || (_MenuItem8 = _jsx(MenuItem, {
|
|
246
|
+
disabled: true,
|
|
247
|
+
children: "Test2"
|
|
248
|
+
}))]
|
|
249
|
+
})),
|
|
195
250
|
getByRole = _render7.getByRole,
|
|
196
251
|
getAllByRole = _render7.getAllByRole,
|
|
197
252
|
queryByText = _render7.queryByText;
|
|
@@ -207,11 +262,17 @@ describe('<Menu />', () => {
|
|
|
207
262
|
expect(menuItem2).toBeInTheDocument();
|
|
208
263
|
});
|
|
209
264
|
it('should not show by default', () => {
|
|
210
|
-
const _render8 = render(_Menu7 || (_Menu7 =
|
|
211
|
-
trigger:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
265
|
+
const _render8 = render(_Menu7 || (_Menu7 = _jsxs(Menu, {
|
|
266
|
+
trigger: _jsx("button", {
|
|
267
|
+
children: "More"
|
|
268
|
+
}),
|
|
269
|
+
children: [_jsx(MenuItem, {
|
|
270
|
+
children: "Test1"
|
|
271
|
+
}), _jsx(MenuItem, {
|
|
272
|
+
disabled: true,
|
|
273
|
+
children: "Test2"
|
|
274
|
+
})]
|
|
275
|
+
}))),
|
|
215
276
|
queryByText = _render8.queryByText,
|
|
216
277
|
getByRole = _render8.getByRole;
|
|
217
278
|
const triggerButton = getByRole('button', {
|
|
@@ -224,12 +285,18 @@ describe('<Menu />', () => {
|
|
|
224
285
|
expect(menuItem2).not.toBeInTheDocument();
|
|
225
286
|
});
|
|
226
287
|
it('should accept a default show', () => {
|
|
227
|
-
const _render9 = render(_Menu8 || (_Menu8 =
|
|
228
|
-
trigger:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
288
|
+
const _render9 = render(_Menu8 || (_Menu8 = _jsxs(Menu, {
|
|
289
|
+
trigger: _jsx("button", {
|
|
290
|
+
children: "More"
|
|
291
|
+
}),
|
|
292
|
+
defaultShow: true,
|
|
293
|
+
children: [_jsx(MenuItem, {
|
|
294
|
+
children: "Test1"
|
|
295
|
+
}), _jsx(MenuItem, {
|
|
296
|
+
disabled: true,
|
|
297
|
+
children: "Test2"
|
|
298
|
+
})]
|
|
299
|
+
}))),
|
|
233
300
|
queryByText = _render9.queryByText,
|
|
234
301
|
getByRole = _render9.getByRole;
|
|
235
302
|
const triggerButton = getByRole('button', {
|
|
@@ -243,59 +310,89 @@ describe('<Menu />', () => {
|
|
|
243
310
|
});
|
|
244
311
|
it('should provide a menu ref', () => {
|
|
245
312
|
const menuRef = vi.fn();
|
|
246
|
-
render(
|
|
247
|
-
trigger: _button4 || (_button4 =
|
|
313
|
+
render(_jsxs(Menu, {
|
|
314
|
+
trigger: _button4 || (_button4 = _jsx("button", {
|
|
315
|
+
children: "More"
|
|
316
|
+
})),
|
|
248
317
|
defaultShow: true,
|
|
249
|
-
menuRef: menuRef
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
318
|
+
menuRef: menuRef,
|
|
319
|
+
children: [_MenuItem9 || (_MenuItem9 = _jsx(MenuItem, {
|
|
320
|
+
children: "Learning Mastery"
|
|
321
|
+
})), _MenuItem10 || (_MenuItem10 = _jsx(MenuItem, {
|
|
322
|
+
disabled: true,
|
|
323
|
+
children: "Gradebook"
|
|
324
|
+
}))]
|
|
325
|
+
}));
|
|
253
326
|
const menu = screen.getByRole('menu');
|
|
254
327
|
expect(menuRef).toHaveBeenCalledWith(menu);
|
|
255
328
|
});
|
|
256
329
|
it('should provide a popoverRef ref', () => {
|
|
257
330
|
const popoverRef = vi.fn();
|
|
258
|
-
render(
|
|
259
|
-
trigger: _button5 || (_button5 =
|
|
331
|
+
render(_jsxs(Menu, {
|
|
332
|
+
trigger: _button5 || (_button5 = _jsx("button", {
|
|
333
|
+
children: "More"
|
|
334
|
+
})),
|
|
260
335
|
defaultShow: true,
|
|
261
|
-
popoverRef: popoverRef
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
336
|
+
popoverRef: popoverRef,
|
|
337
|
+
children: [_MenuItem11 || (_MenuItem11 = _jsx(MenuItem, {
|
|
338
|
+
children: "Learning Mastery"
|
|
339
|
+
})), _MenuItem12 || (_MenuItem12 = _jsx(MenuItem, {
|
|
340
|
+
disabled: true,
|
|
341
|
+
children: "Gradebook"
|
|
342
|
+
}))]
|
|
343
|
+
}));
|
|
265
344
|
expect(popoverRef).toHaveBeenCalled();
|
|
266
345
|
});
|
|
267
346
|
it('should call onToggle on click', () => {
|
|
268
347
|
const onToggle = vi.fn();
|
|
269
|
-
render(
|
|
270
|
-
trigger: _button6 || (_button6 =
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
348
|
+
render(_jsxs(Menu, {
|
|
349
|
+
trigger: _button6 || (_button6 = _jsx("button", {
|
|
350
|
+
children: "More"
|
|
351
|
+
})),
|
|
352
|
+
onToggle: onToggle,
|
|
353
|
+
children: [_MenuItem13 || (_MenuItem13 = _jsx(MenuItem, {
|
|
354
|
+
children: "Learning Mastery"
|
|
355
|
+
})), _MenuItem14 || (_MenuItem14 = _jsx(MenuItem, {
|
|
356
|
+
disabled: true,
|
|
357
|
+
children: "Gradebook"
|
|
358
|
+
}))]
|
|
359
|
+
}));
|
|
275
360
|
const trigger = screen.getByRole('button');
|
|
276
361
|
fireEvent.click(trigger);
|
|
277
362
|
expect(onToggle).toHaveBeenCalled();
|
|
278
363
|
});
|
|
279
364
|
it('should have an aria-haspopup attribute', () => {
|
|
280
|
-
render(_Menu9 || (_Menu9 =
|
|
281
|
-
trigger:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
365
|
+
render(_Menu9 || (_Menu9 = _jsxs(Menu, {
|
|
366
|
+
trigger: _jsx("button", {
|
|
367
|
+
children: "More"
|
|
368
|
+
}),
|
|
369
|
+
children: [_jsx(MenuItem, {
|
|
370
|
+
children: "Learning Mastery"
|
|
371
|
+
}), _jsx(MenuItem, {
|
|
372
|
+
disabled: true,
|
|
373
|
+
children: "Gradebook"
|
|
374
|
+
})]
|
|
375
|
+
})));
|
|
285
376
|
const trigger = screen.getByRole('button');
|
|
286
377
|
expect(trigger).toHaveAttribute('aria-haspopup');
|
|
287
378
|
});
|
|
288
379
|
it('should pass positionContainerDisplay prop to Popover', () => {
|
|
289
380
|
let popoverRef = null;
|
|
290
|
-
render(
|
|
291
|
-
trigger: _button7 || (_button7 =
|
|
381
|
+
render(_jsxs(Menu, {
|
|
382
|
+
trigger: _button7 || (_button7 = _jsx("button", {
|
|
383
|
+
children: "More"
|
|
384
|
+
})),
|
|
292
385
|
popoverRef: e => {
|
|
293
386
|
popoverRef = e;
|
|
294
387
|
},
|
|
295
|
-
positionContainerDisplay: "block"
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
388
|
+
positionContainerDisplay: "block",
|
|
389
|
+
children: [_MenuItem15 || (_MenuItem15 = _jsx(MenuItem, {
|
|
390
|
+
children: "Learning Mastery"
|
|
391
|
+
})), _MenuItem16 || (_MenuItem16 = _jsx(MenuItem, {
|
|
392
|
+
disabled: true,
|
|
393
|
+
children: "Gradebook"
|
|
394
|
+
}))]
|
|
395
|
+
}));
|
|
299
396
|
const popoverProps = popoverRef.props;
|
|
300
397
|
expect(popoverProps.positionContainerDisplay).toBe('block');
|
|
301
398
|
});
|
package/es/Menu/index.js
CHANGED
|
@@ -22,8 +22,8 @@ var _dec, _dec2, _dec3, _class, _Menu;
|
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
import
|
|
25
|
+
|
|
26
|
+
import { Children, Component } from 'react';
|
|
27
27
|
import keycode from 'keycode';
|
|
28
28
|
import { Popover } from '@instructure/ui-popover';
|
|
29
29
|
import { safeCloneElement, matchComponentTypes, withDeterministicId } from '@instructure/ui-react-utils';
|
|
@@ -34,10 +34,11 @@ import { MenuContext } from '../MenuContext';
|
|
|
34
34
|
import { MenuItem } from './MenuItem';
|
|
35
35
|
import { MenuItemGroup } from './MenuItemGroup';
|
|
36
36
|
import { MenuItemSeparator } from './MenuItemSeparator';
|
|
37
|
-
import { withStyle
|
|
37
|
+
import { withStyle } from '@instructure/emotion';
|
|
38
38
|
import generateStyle from './styles';
|
|
39
39
|
import generateComponentTheme from './theme';
|
|
40
40
|
import { propTypes, allowedProps } from './props';
|
|
41
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
41
42
|
/**
|
|
42
43
|
---
|
|
43
44
|
category: components
|
|
@@ -276,15 +277,16 @@ let Menu = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gener
|
|
|
276
277
|
withArrow: false,
|
|
277
278
|
onToggle: this.handleSubMenuToggle,
|
|
278
279
|
onDismiss: this.handleSubMenuDismiss,
|
|
279
|
-
trigger:
|
|
280
|
+
trigger: _jsx(MenuItem, {
|
|
280
281
|
onMouseOver: this.handleMenuItemMouseOver,
|
|
281
282
|
onFocus: this.handleMenuItemFocus,
|
|
282
283
|
onBlur: this.handleMenuItemBlur,
|
|
283
284
|
tabIndex: isTabbable ? 0 : -1,
|
|
284
285
|
type: "flyout",
|
|
285
286
|
disabled: submenuDisabled,
|
|
286
|
-
renderLabelInfo: child.props.renderLabelInfo
|
|
287
|
-
|
|
287
|
+
renderLabelInfo: child.props.renderLabelInfo,
|
|
288
|
+
children: child.props.title || child.props.label
|
|
289
|
+
})
|
|
288
290
|
});
|
|
289
291
|
}
|
|
290
292
|
return;
|
|
@@ -299,23 +301,25 @@ let Menu = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gener
|
|
|
299
301
|
onKeyUp = _this$props4.onKeyUp;
|
|
300
302
|
const labelledBy = this.props['aria-labelledby'];
|
|
301
303
|
const controls = this.props['aria-controls'];
|
|
302
|
-
return
|
|
304
|
+
return _jsx(MenuContext.Provider, {
|
|
303
305
|
value: {
|
|
304
306
|
removeMenuItem: this.removeMenuItem,
|
|
305
307
|
registerMenuItem: this.registerMenuItem
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
308
|
+
},
|
|
309
|
+
children: _jsx("div", {
|
|
310
|
+
role: "menu",
|
|
311
|
+
"aria-label": label,
|
|
312
|
+
tabIndex: 0,
|
|
313
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menu,
|
|
314
|
+
"aria-labelledby": labelledBy || (trigger ? this._labelId : void 0),
|
|
315
|
+
"aria-controls": controls,
|
|
316
|
+
"aria-disabled": disabled ? 'true' : void 0,
|
|
317
|
+
onKeyDown: this.handleMenuKeyDown,
|
|
318
|
+
onKeyUp: onKeyUp,
|
|
319
|
+
ref: this.handleRef,
|
|
320
|
+
children: this.renderChildren()
|
|
321
|
+
})
|
|
322
|
+
});
|
|
319
323
|
}
|
|
320
324
|
render() {
|
|
321
325
|
const _this$props5 = this.props,
|
|
@@ -333,7 +337,7 @@ let Menu = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gener
|
|
|
333
337
|
positionContainerDisplay = _this$props5.positionContainerDisplay,
|
|
334
338
|
offsetX = _this$props5.offsetX,
|
|
335
339
|
offsetY = _this$props5.offsetY;
|
|
336
|
-
return trigger ?
|
|
340
|
+
return trigger ? _jsx(Popover, {
|
|
337
341
|
isShowingContent: show,
|
|
338
342
|
defaultIsShowingContent: defaultShow,
|
|
339
343
|
onHideContent: (event, {
|
|
@@ -375,8 +379,9 @@ let Menu = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gener
|
|
|
375
379
|
onMouseOver: this.handleTriggerMouseOver,
|
|
376
380
|
onKeyDown: this.handleTriggerKeyDown,
|
|
377
381
|
disabled: trigger.props.disabled || disabled
|
|
378
|
-
})
|
|
379
|
-
|
|
382
|
+
}),
|
|
383
|
+
children: this.renderMenu()
|
|
384
|
+
}) : this.renderMenu();
|
|
380
385
|
}
|
|
381
386
|
}, _Menu.displayName = "Menu", _Menu.componentId = 'Menu', _Menu.propTypes = propTypes, _Menu.allowedProps = allowedProps, _Menu.defaultProps = {
|
|
382
387
|
label: null,
|