@instructure/ui-menu 8.13.1-snapshot.2 → 8.13.1-snapshot.27
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/es/Menu/MenuItem/index.js +28 -21
- package/es/Menu/MenuItem/props.js +0 -23
- package/es/Menu/MenuItemGroup/index.js +17 -13
- package/es/Menu/MenuItemGroup/props.js +1 -30
- package/es/Menu/MenuItemSeparator/index.js +6 -2
- package/es/Menu/index.js +56 -52
- package/es/Menu/props.js +1 -113
- package/es/MenuContext.js +3 -3
- package/lib/Menu/MenuItem/index.js +28 -21
- package/lib/Menu/MenuItem/props.js +0 -23
- package/lib/Menu/MenuItemGroup/index.js +17 -13
- package/lib/Menu/MenuItemGroup/props.js +1 -30
- package/lib/Menu/MenuItemSeparator/index.js +6 -2
- package/lib/Menu/index.js +58 -52
- package/lib/Menu/props.js +1 -113
- package/lib/MenuContext.js +2 -2
- package/package.json +21 -21
- package/src/Menu/MenuItem/index.tsx +24 -34
- package/src/Menu/MenuItem/props.ts +36 -27
- package/src/Menu/MenuItemGroup/index.tsx +28 -48
- package/src/Menu/MenuItemGroup/props.ts +37 -30
- package/src/Menu/MenuItemSeparator/index.tsx +2 -4
- package/src/Menu/index.tsx +79 -133
- package/src/Menu/props.ts +76 -84
- package/src/MenuContext.ts +3 -2
- package/tsconfig.build.json +25 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
- package/types/Menu/MenuItem/index.d.ts +24 -23
- package/types/Menu/MenuItem/index.d.ts.map +1 -1
- package/types/Menu/MenuItem/props.d.ts +30 -7
- package/types/Menu/MenuItem/props.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
- package/types/Menu/MenuItemGroup/index.d.ts +22 -22
- package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/props.d.ts +33 -8
- package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
- package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
- package/types/Menu/MenuLocator.d.ts +576 -576
- package/types/Menu/index.d.ts +57 -67
- package/types/Menu/index.d.ts.map +1 -1
- package/types/Menu/props.d.ts +94 -16
- package/types/Menu/props.d.ts.map +1 -1
- package/types/MenuContext.d.ts +3 -2
- package/types/MenuContext.d.ts.map +1 -1
package/src/Menu/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
/** @jsx jsx */
|
|
25
|
-
import { Children, Component, ReactElement } from 'react'
|
|
25
|
+
import React, { Children, Component, ReactElement } from 'react'
|
|
26
26
|
import keycode from 'keycode'
|
|
27
27
|
|
|
28
28
|
import { Popover } from '@instructure/ui-popover'
|
|
@@ -37,6 +37,7 @@ import { testable } from '@instructure/ui-testable'
|
|
|
37
37
|
|
|
38
38
|
import { MenuContext } from '../MenuContext'
|
|
39
39
|
import { MenuItem } from './MenuItem'
|
|
40
|
+
import type { OnMenuItemSelect, MenuItemProps } from './MenuItem/props'
|
|
40
41
|
import { MenuItemGroup } from './MenuItemGroup'
|
|
41
42
|
import { MenuItemSeparator } from './MenuItemSeparator'
|
|
42
43
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
@@ -51,6 +52,7 @@ import type { MenuProps } from './props'
|
|
|
51
52
|
---
|
|
52
53
|
category: components
|
|
53
54
|
---
|
|
55
|
+
@tsProps
|
|
54
56
|
**/
|
|
55
57
|
@withStyle(generateStyle, generateComponentTheme)
|
|
56
58
|
@testable()
|
|
@@ -60,35 +62,13 @@ class Menu extends Component<MenuProps> {
|
|
|
60
62
|
static propTypes = propTypes
|
|
61
63
|
static allowedProps = allowedProps
|
|
62
64
|
static defaultProps = {
|
|
63
|
-
children: null,
|
|
64
65
|
label: null,
|
|
65
66
|
disabled: false,
|
|
66
67
|
trigger: null,
|
|
67
68
|
placement: 'bottom center',
|
|
68
69
|
defaultShow: false,
|
|
69
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'shown' is declared but its value is never read.
|
|
70
|
-
onToggle: (shown, menu) => {},
|
|
71
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
72
|
-
onSelect: (event, value, selected, item) => {},
|
|
73
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
74
|
-
onDismiss: (event, documentClick) => {},
|
|
75
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
76
|
-
onBlur: (event) => {},
|
|
77
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
78
|
-
onFocus: (event) => {},
|
|
79
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
80
|
-
onMouseOver: (event) => {},
|
|
81
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
82
|
-
onKeyDown: (event) => {},
|
|
83
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
84
|
-
onKeyUp: (event) => {},
|
|
85
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
86
|
-
menuRef: (el) => {},
|
|
87
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
88
|
-
popoverRef: (el) => {},
|
|
89
70
|
mountNode: null,
|
|
90
71
|
constrain: 'window',
|
|
91
|
-
liveRegion: null,
|
|
92
72
|
shouldHideOnSelect: true,
|
|
93
73
|
shouldFocusTriggerOnClose: true,
|
|
94
74
|
withArrow: true,
|
|
@@ -102,14 +82,15 @@ class Menu extends Component<MenuProps> {
|
|
|
102
82
|
|
|
103
83
|
state = { hasFocus: false }
|
|
104
84
|
_rootNode = null
|
|
105
|
-
_menuItems = []
|
|
106
|
-
_popover = null
|
|
107
|
-
_trigger = null
|
|
85
|
+
_menuItems: MenuItem[] = []
|
|
86
|
+
_popover: Popover | null = null
|
|
87
|
+
_trigger: MenuItem | (ReactElement & { focus?: () => void }) | null = null
|
|
108
88
|
_menu: HTMLUListElement | null = null
|
|
109
89
|
_labelId = uid('Menu__label')
|
|
110
|
-
_activeSubMenu
|
|
90
|
+
_activeSubMenu?: Menu | null
|
|
91
|
+
_id: string
|
|
111
92
|
|
|
112
|
-
ref:
|
|
93
|
+
ref: ReactElement | null = null
|
|
113
94
|
|
|
114
95
|
handleRef = (el: HTMLUListElement | null) => {
|
|
115
96
|
const { menuRef } = this.props
|
|
@@ -119,34 +100,27 @@ class Menu extends Component<MenuProps> {
|
|
|
119
100
|
}
|
|
120
101
|
}
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
constructor(props) {
|
|
103
|
+
constructor(props: MenuProps) {
|
|
124
104
|
super(props)
|
|
125
|
-
|
|
105
|
+
|
|
126
106
|
this._id = this.props.id || uid('Menu')
|
|
127
107
|
}
|
|
128
108
|
|
|
129
109
|
componentDidMount() {
|
|
130
|
-
|
|
131
|
-
this.props.makeStyles()
|
|
110
|
+
this.props.makeStyles?.()
|
|
132
111
|
}
|
|
133
112
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
|
|
137
|
-
this.props.makeStyles()
|
|
113
|
+
componentDidUpdate() {
|
|
114
|
+
this.props.makeStyles?.()
|
|
138
115
|
}
|
|
139
116
|
|
|
140
117
|
static contextType = MenuContext
|
|
141
118
|
|
|
142
|
-
|
|
143
|
-
registerMenuItem = (item) => {
|
|
144
|
-
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'any' is not assignable to parame... Remove this comment to see the full error message
|
|
119
|
+
registerMenuItem = (item: MenuItem) => {
|
|
145
120
|
this._menuItems.push(item)
|
|
146
121
|
}
|
|
147
122
|
|
|
148
|
-
|
|
149
|
-
removeMenuItem = (item) => {
|
|
123
|
+
removeMenuItem = (item: MenuItem) => {
|
|
150
124
|
const index = this.getMenuItemIndex(item)
|
|
151
125
|
error(index >= 0, '[Menu] Could not find registered menu item.')
|
|
152
126
|
if (index >= 0) {
|
|
@@ -158,39 +132,34 @@ class Menu extends Component<MenuProps> {
|
|
|
158
132
|
return this._menuItems
|
|
159
133
|
}
|
|
160
134
|
|
|
161
|
-
|
|
162
|
-
getMenuItemIndex = (item) => {
|
|
135
|
+
getMenuItemIndex = (item: MenuItem) => {
|
|
163
136
|
return this._menuItems.findIndex((i) => i === item)
|
|
164
137
|
}
|
|
165
138
|
|
|
166
|
-
|
|
167
|
-
handleTriggerKeyDown = (event) => {
|
|
139
|
+
handleTriggerKeyDown = (event: React.KeyboardEvent) => {
|
|
168
140
|
if (this.props.type === 'flyout' && event.keyCode === keycode.codes.right) {
|
|
169
141
|
event.persist()
|
|
170
|
-
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
|
171
142
|
this.show()
|
|
172
143
|
}
|
|
173
144
|
}
|
|
174
145
|
|
|
175
146
|
handleTriggerMouseOver = () => {
|
|
176
147
|
if (this.props.type === 'flyout') {
|
|
177
|
-
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
|
178
148
|
this.show()
|
|
179
149
|
}
|
|
180
150
|
}
|
|
181
151
|
|
|
182
|
-
|
|
183
|
-
handleToggle = (shown) => {
|
|
152
|
+
handleToggle = (shown: boolean) => {
|
|
184
153
|
if (typeof this.props.onToggle === 'function') {
|
|
185
154
|
this.props.onToggle(shown, this)
|
|
186
155
|
}
|
|
187
156
|
}
|
|
188
157
|
|
|
189
|
-
|
|
190
|
-
handleMenuKeyDown = (event) => {
|
|
158
|
+
handleMenuKeyDown = (event: React.KeyboardEvent) => {
|
|
191
159
|
const key = event && event.keyCode
|
|
192
|
-
|
|
193
|
-
const
|
|
160
|
+
const { down, up, tab, left } = keycode.codes
|
|
161
|
+
const pgdn = keycode.codes['page down']
|
|
162
|
+
const pgup = keycode.codes['page up']
|
|
194
163
|
|
|
195
164
|
if (key === down || key === pgdn) {
|
|
196
165
|
event.preventDefault()
|
|
@@ -212,8 +181,7 @@ class Menu extends Component<MenuProps> {
|
|
|
212
181
|
}
|
|
213
182
|
}
|
|
214
183
|
|
|
215
|
-
|
|
216
|
-
handleMenuItemSelect = (event, value, selected, item) => {
|
|
184
|
+
handleMenuItemSelect: OnMenuItemSelect = (event, value, selected, item) => {
|
|
217
185
|
if (this.props.shouldHideOnSelect) {
|
|
218
186
|
this.hide(event)
|
|
219
187
|
}
|
|
@@ -231,67 +199,57 @@ class Menu extends Component<MenuProps> {
|
|
|
231
199
|
this.setState({ hasFocus: this.focusedIndex >= 0 })
|
|
232
200
|
}
|
|
233
201
|
|
|
234
|
-
|
|
235
|
-
handleMenuItemMouseOver = (event, menuItem) => {
|
|
236
|
-
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
202
|
+
handleMenuItemMouseOver: MenuItemProps['onMouseOver'] = (event, menuItem) => {
|
|
237
203
|
if (this._activeSubMenu && menuItem !== this._activeSubMenu._trigger) {
|
|
238
204
|
this.hideActiveSubMenu(event)
|
|
239
205
|
}
|
|
240
206
|
}
|
|
241
207
|
|
|
242
|
-
|
|
243
|
-
hideActiveSubMenu = (event) => {
|
|
208
|
+
hideActiveSubMenu = (event: React.MouseEvent | React.KeyboardEvent) => {
|
|
244
209
|
if (this._activeSubMenu) {
|
|
245
|
-
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
246
210
|
this._activeSubMenu.hide(event)
|
|
247
211
|
this._activeSubMenu = null
|
|
248
212
|
}
|
|
249
213
|
}
|
|
250
214
|
|
|
251
|
-
|
|
252
|
-
handleSubMenuToggle = (shown, subMenu) => {
|
|
215
|
+
handleSubMenuToggle: MenuProps['onToggle'] = (shown, subMenu) => {
|
|
253
216
|
if (shown) {
|
|
254
217
|
this._activeSubMenu = subMenu
|
|
255
218
|
}
|
|
256
219
|
}
|
|
257
220
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
221
|
+
handleSubMenuDismiss = (
|
|
222
|
+
event: React.MouseEvent | React.KeyboardEvent,
|
|
223
|
+
documentClick: boolean
|
|
224
|
+
) => {
|
|
225
|
+
if (
|
|
226
|
+
(event && (event as React.KeyboardEvent).keyCode === keycode.codes.tab) ||
|
|
227
|
+
documentClick
|
|
228
|
+
) {
|
|
261
229
|
this.hide(event)
|
|
262
230
|
}
|
|
263
231
|
}
|
|
264
232
|
|
|
265
|
-
|
|
266
|
-
hide = (event) => {
|
|
233
|
+
hide = (event: React.MouseEvent | React.KeyboardEvent) => {
|
|
267
234
|
if (this._popover) {
|
|
268
|
-
|
|
269
|
-
this._popover.hide(event)
|
|
235
|
+
this._popover.hide(event as unknown as Event)
|
|
270
236
|
}
|
|
271
237
|
}
|
|
272
238
|
|
|
273
|
-
|
|
274
|
-
show = (event) => {
|
|
239
|
+
show = (event?: React.MouseEvent | React.KeyboardEvent) => {
|
|
275
240
|
if (this._popover) {
|
|
276
|
-
//
|
|
277
|
-
this._popover.show(event)
|
|
241
|
+
//TODO make events consistents
|
|
242
|
+
this._popover.show(event as unknown as Event)
|
|
278
243
|
}
|
|
279
244
|
}
|
|
280
245
|
|
|
281
246
|
focus() {
|
|
282
247
|
if (this.shown) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
286
|
-
this._menu.focus()
|
|
248
|
+
error(!!this._menu?.focus, '[Menu] Could not focus the menu.')
|
|
249
|
+
this._menu!.focus()
|
|
287
250
|
} else {
|
|
288
|
-
error(
|
|
289
|
-
|
|
290
|
-
this._trigger && this._trigger.focus,
|
|
291
|
-
'[Menu] Could not focus the trigger.'
|
|
292
|
-
)
|
|
293
|
-
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
294
|
-
this._trigger.focus()
|
|
251
|
+
error(!!this._trigger?.focus, '[Menu] Could not focus the trigger.')
|
|
252
|
+
this._trigger!.focus!()
|
|
295
253
|
}
|
|
296
254
|
}
|
|
297
255
|
|
|
@@ -305,13 +263,11 @@ class Menu extends Component<MenuProps> {
|
|
|
305
263
|
|
|
306
264
|
get focusedIndex() {
|
|
307
265
|
return this.menuItems.findIndex((item) => {
|
|
308
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'focused' does not exist on type 'never'.
|
|
309
266
|
return item && item.focused === true
|
|
310
267
|
})
|
|
311
268
|
}
|
|
312
269
|
|
|
313
|
-
|
|
314
|
-
moveFocus(step) {
|
|
270
|
+
moveFocus(step: number) {
|
|
315
271
|
const count = this.menuItems ? this.menuItems.length : 0
|
|
316
272
|
|
|
317
273
|
if (count <= 0) {
|
|
@@ -322,15 +278,15 @@ class Menu extends Component<MenuProps> {
|
|
|
322
278
|
|
|
323
279
|
const nextItem = this.menuItems[(current + count + step) % count]
|
|
324
280
|
|
|
325
|
-
|
|
326
|
-
|
|
281
|
+
error(
|
|
282
|
+
typeof nextItem !== 'undefined' && typeof nextItem.focus !== 'undefined',
|
|
283
|
+
'[Menu] Could not focus next menu item.'
|
|
284
|
+
)
|
|
327
285
|
|
|
328
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'focus' does not exist on type 'never'.
|
|
329
286
|
nextItem.focus()
|
|
330
287
|
}
|
|
331
288
|
|
|
332
289
|
get shown() {
|
|
333
|
-
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
334
290
|
return this._popover ? this._popover.shown : true
|
|
335
291
|
}
|
|
336
292
|
|
|
@@ -339,7 +295,6 @@ class Menu extends Component<MenuProps> {
|
|
|
339
295
|
|
|
340
296
|
let count = 0
|
|
341
297
|
|
|
342
|
-
// @ts-expect-error ts-migrate(7030) FIXME: Not all code paths return a value.
|
|
343
298
|
return Children.map(children, (child) => {
|
|
344
299
|
if (
|
|
345
300
|
!matchComponentTypes(child, [
|
|
@@ -359,30 +314,29 @@ class Menu extends Component<MenuProps> {
|
|
|
359
314
|
if (matchComponentTypes(child, ['MenuItemSeparator'])) {
|
|
360
315
|
return <li role="none">{child}</li>
|
|
361
316
|
}
|
|
317
|
+
const menuItemChild = child as MenuItem
|
|
362
318
|
|
|
363
319
|
const controls =
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
369
|
-
this.props['aria-controls'] || // eslint-disable-line react/prop-types
|
|
370
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'controls' does not exist on type 'Readon... Remove this comment to see the full error message
|
|
371
|
-
this.props.controls // eslint-disable-line react/prop-types
|
|
320
|
+
menuItemChild.props['aria-controls'] ||
|
|
321
|
+
menuItemChild.props.controls ||
|
|
322
|
+
this.props['aria-controls'] ||
|
|
323
|
+
this.props.controls
|
|
372
324
|
|
|
373
325
|
if (matchComponentTypes(child, ['MenuItem'])) {
|
|
374
326
|
return (
|
|
375
327
|
<li role="none">
|
|
376
|
-
{safeCloneElement(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
328
|
+
{safeCloneElement(
|
|
329
|
+
child as ReactElement,
|
|
330
|
+
{
|
|
331
|
+
controls,
|
|
332
|
+
disabled: disabled || (child as MenuItem).props.disabled,
|
|
333
|
+
onFocus: this.handleMenuItemFocus,
|
|
334
|
+
onBlur: this.handleMenuItemBlur,
|
|
335
|
+
onSelect: this.handleMenuItemSelect,
|
|
336
|
+
onMouseOver: this.handleMenuItemMouseOver,
|
|
337
|
+
tabIndex: isTabbable ? 0 : -1
|
|
338
|
+
} as Partial<MenuItemProps>
|
|
339
|
+
)}
|
|
386
340
|
</li>
|
|
387
341
|
)
|
|
388
342
|
}
|
|
@@ -392,8 +346,7 @@ class Menu extends Component<MenuProps> {
|
|
|
392
346
|
<li role="none">
|
|
393
347
|
{safeCloneElement(child as ReactElement, {
|
|
394
348
|
controls,
|
|
395
|
-
|
|
396
|
-
disabled: disabled || child.props.disabled,
|
|
349
|
+
disabled: disabled || (child as MenuItemGroup).props.disabled,
|
|
397
350
|
onFocus: this.handleMenuItemFocus,
|
|
398
351
|
onBlur: this.handleMenuItemBlur,
|
|
399
352
|
onSelect: this.handleMenuItemSelect,
|
|
@@ -405,8 +358,7 @@ class Menu extends Component<MenuProps> {
|
|
|
405
358
|
}
|
|
406
359
|
|
|
407
360
|
if (matchComponentTypes(child, ['Menu'])) {
|
|
408
|
-
|
|
409
|
-
const submenuDisabled = disabled || child.props.disabled
|
|
361
|
+
const submenuDisabled = disabled || (child as Menu).props.disabled
|
|
410
362
|
|
|
411
363
|
return (
|
|
412
364
|
<li role="none">
|
|
@@ -430,31 +382,27 @@ class Menu extends Component<MenuProps> {
|
|
|
430
382
|
type="flyout"
|
|
431
383
|
disabled={submenuDisabled}
|
|
432
384
|
>
|
|
433
|
-
{
|
|
434
|
-
{child.props.title || child.props.label}
|
|
385
|
+
{(child as Menu).props.title || (child as Menu).props.label}
|
|
435
386
|
</MenuItem>
|
|
436
387
|
)
|
|
437
388
|
})}
|
|
438
389
|
</li>
|
|
439
390
|
)
|
|
440
391
|
}
|
|
392
|
+
return
|
|
441
393
|
})
|
|
442
394
|
}
|
|
443
395
|
|
|
444
396
|
renderMenu() {
|
|
445
397
|
const { disabled, label, trigger, onKeyUp } = this.props
|
|
446
398
|
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
450
|
-
const controls = this.props['aria-controls'] // eslint-disable-line react/prop-types
|
|
399
|
+
const labelledBy = this.props['aria-labelledby']
|
|
400
|
+
const controls = this.props['aria-controls']
|
|
451
401
|
|
|
452
402
|
return (
|
|
453
403
|
<MenuContext.Provider
|
|
454
404
|
value={{
|
|
455
|
-
// @ts-expect-error ts-migrate(2322) FIXME: Type '(item: any) => void' is not assignable to ty... Remove this comment to see the full error message
|
|
456
405
|
removeMenuItem: this.removeMenuItem,
|
|
457
|
-
// @ts-expect-error ts-migrate(2322) FIXME: Type '(item: any) => void' is not assignable to ty... Remove this comment to see the full error message
|
|
458
406
|
registerMenuItem: this.registerMenuItem
|
|
459
407
|
}}
|
|
460
408
|
>
|
|
@@ -463,7 +411,7 @@ class Menu extends Component<MenuProps> {
|
|
|
463
411
|
aria-label={label}
|
|
464
412
|
tabIndex={0}
|
|
465
413
|
css={this.props.styles?.menu}
|
|
466
|
-
aria-labelledby={labelledBy || (trigger
|
|
414
|
+
aria-labelledby={labelledBy || (trigger ? this._labelId : undefined)}
|
|
467
415
|
aria-controls={controls}
|
|
468
416
|
aria-disabled={disabled ? 'true' : undefined}
|
|
469
417
|
onKeyDown={this.handleMenuKeyDown}
|
|
@@ -498,15 +446,15 @@ class Menu extends Component<MenuProps> {
|
|
|
498
446
|
isShowingContent={show}
|
|
499
447
|
defaultIsShowingContent={defaultShow}
|
|
500
448
|
onHideContent={(event, { documentClick }) => {
|
|
501
|
-
|
|
502
|
-
|
|
449
|
+
if (typeof onDismiss === 'function') {
|
|
450
|
+
onDismiss(event, documentClick)
|
|
451
|
+
}
|
|
503
452
|
this.handleToggle(false)
|
|
504
453
|
}}
|
|
505
454
|
onShowContent={() => this.handleToggle(true)}
|
|
506
455
|
mountNode={mountNode}
|
|
507
456
|
placement={placement}
|
|
508
457
|
withArrow={withArrow}
|
|
509
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_id' does not exist on type 'Menu'.
|
|
510
458
|
id={this._id}
|
|
511
459
|
on={['click']}
|
|
512
460
|
shouldContainFocus
|
|
@@ -516,23 +464,21 @@ class Menu extends Component<MenuProps> {
|
|
|
516
464
|
offsetX={offsetX}
|
|
517
465
|
offsetY={offsetY}
|
|
518
466
|
ref={(el) => {
|
|
519
|
-
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Popover | null' is not assignable to type 'n... Remove this comment to see the full error message
|
|
520
467
|
this._popover = el
|
|
521
468
|
if (typeof popoverRef === 'function') {
|
|
522
469
|
popoverRef(el)
|
|
523
470
|
}
|
|
524
471
|
}}
|
|
525
472
|
renderTrigger={safeCloneElement(trigger as ReactElement, {
|
|
526
|
-
|
|
527
|
-
|
|
473
|
+
ref: (el: ReactElement) => {
|
|
474
|
+
this._trigger = el
|
|
528
475
|
this.ref = el
|
|
529
476
|
},
|
|
530
477
|
'aria-haspopup': true,
|
|
531
478
|
id: this._labelId,
|
|
532
479
|
onMouseOver: this.handleTriggerMouseOver,
|
|
533
480
|
onKeyDown: this.handleTriggerKeyDown,
|
|
534
|
-
|
|
535
|
-
disabled: trigger.props.disabled || disabled
|
|
481
|
+
disabled: (trigger as ReactElement).props.disabled || disabled
|
|
536
482
|
})}
|
|
537
483
|
>
|
|
538
484
|
{this.renderMenu()}
|