@instructure/ui-menu 8.13.1-snapshot.9 → 8.14.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/es/Menu/MenuItem/index.js +28 -21
  3. package/es/Menu/MenuItem/props.js +0 -23
  4. package/es/Menu/MenuItemGroup/index.js +17 -13
  5. package/es/Menu/MenuItemGroup/props.js +1 -30
  6. package/es/Menu/MenuItemSeparator/index.js +6 -2
  7. package/es/Menu/index.js +59 -56
  8. package/es/Menu/props.js +1 -113
  9. package/es/MenuContext.js +3 -3
  10. package/lib/Menu/MenuItem/index.js +28 -21
  11. package/lib/Menu/MenuItem/props.js +0 -23
  12. package/lib/Menu/MenuItemGroup/index.js +17 -13
  13. package/lib/Menu/MenuItemGroup/props.js +1 -30
  14. package/lib/Menu/MenuItemSeparator/index.js +6 -2
  15. package/lib/Menu/index.js +61 -56
  16. package/lib/Menu/props.js +1 -113
  17. package/lib/MenuContext.js +2 -2
  18. package/package.json +21 -22
  19. package/src/Menu/MenuItem/index.tsx +24 -34
  20. package/src/Menu/MenuItem/props.ts +36 -27
  21. package/src/Menu/MenuItemGroup/index.tsx +28 -48
  22. package/src/Menu/MenuItemGroup/props.ts +37 -30
  23. package/src/Menu/MenuItemSeparator/index.tsx +2 -4
  24. package/src/Menu/index.tsx +81 -135
  25. package/src/Menu/props.ts +79 -84
  26. package/src/MenuContext.ts +3 -2
  27. package/tsconfig.build.json +25 -2
  28. package/tsconfig.build.tsbuildinfo +1 -0
  29. package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
  30. package/types/Menu/MenuItem/index.d.ts +24 -23
  31. package/types/Menu/MenuItem/index.d.ts.map +1 -1
  32. package/types/Menu/MenuItem/props.d.ts +30 -7
  33. package/types/Menu/MenuItem/props.d.ts.map +1 -1
  34. package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
  35. package/types/Menu/MenuItemGroup/index.d.ts +22 -22
  36. package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
  37. package/types/Menu/MenuItemGroup/props.d.ts +33 -8
  38. package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
  39. package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
  40. package/types/Menu/MenuLocator.d.ts +576 -576
  41. package/types/Menu/index.d.ts +58 -68
  42. package/types/Menu/index.d.ts.map +1 -1
  43. package/types/Menu/props.d.ts +94 -16
  44. package/types/Menu/props.d.ts.map +1 -1
  45. package/types/MenuContext.d.ts +3 -2
  46. package/types/MenuContext.d.ts.map +1 -1
  47. package/LICENSE.md +0 -27
@@ -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,16 @@ 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 | (React.ReactInstance & { focus?: () => void }) | null =
88
+ null
108
89
  _menu: HTMLUListElement | null = null
109
90
  _labelId = uid('Menu__label')
110
- _activeSubMenu = null
91
+ _activeSubMenu?: Menu | null
92
+ _id: string
111
93
 
112
- ref: HTMLUListElement | null = null
94
+ ref: Element | null = null
113
95
 
114
96
  handleRef = (el: HTMLUListElement | null) => {
115
97
  const { menuRef } = this.props
@@ -119,34 +101,27 @@ class Menu extends Component<MenuProps> {
119
101
  }
120
102
  }
121
103
 
122
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
123
- constructor(props) {
104
+ constructor(props: MenuProps) {
124
105
  super(props)
125
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_id' does not exist on type 'Menu'.
106
+
126
107
  this._id = this.props.id || uid('Menu')
127
108
  }
128
109
 
129
110
  componentDidMount() {
130
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
131
- this.props.makeStyles()
111
+ this.props.makeStyles?.()
132
112
  }
133
113
 
134
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
135
- componentDidUpdate(prevProps) {
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()
114
+ componentDidUpdate() {
115
+ this.props.makeStyles?.()
138
116
  }
139
117
 
140
118
  static contextType = MenuContext
141
119
 
142
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'item' implicitly has an 'any' type.
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
120
+ registerMenuItem = (item: MenuItem) => {
145
121
  this._menuItems.push(item)
146
122
  }
147
123
 
148
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'item' implicitly has an 'any' type.
149
- removeMenuItem = (item) => {
124
+ removeMenuItem = (item: MenuItem) => {
150
125
  const index = this.getMenuItemIndex(item)
151
126
  error(index >= 0, '[Menu] Could not find registered menu item.')
152
127
  if (index >= 0) {
@@ -158,39 +133,34 @@ class Menu extends Component<MenuProps> {
158
133
  return this._menuItems
159
134
  }
160
135
 
161
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'item' implicitly has an 'any' type.
162
- getMenuItemIndex = (item) => {
136
+ getMenuItemIndex = (item: MenuItem) => {
163
137
  return this._menuItems.findIndex((i) => i === item)
164
138
  }
165
139
 
166
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
167
- handleTriggerKeyDown = (event) => {
140
+ handleTriggerKeyDown = (event: React.KeyboardEvent) => {
168
141
  if (this.props.type === 'flyout' && event.keyCode === keycode.codes.right) {
169
142
  event.persist()
170
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
171
- this.show()
143
+ this.show(event)
172
144
  }
173
145
  }
174
146
 
175
- handleTriggerMouseOver = () => {
147
+ handleTriggerMouseOver = (event: React.MouseEvent) => {
176
148
  if (this.props.type === 'flyout') {
177
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
178
- this.show()
149
+ this.show(event)
179
150
  }
180
151
  }
181
152
 
182
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'shown' implicitly has an 'any' type.
183
- handleToggle = (shown) => {
153
+ handleToggle = (shown: boolean) => {
184
154
  if (typeof this.props.onToggle === 'function') {
185
155
  this.props.onToggle(shown, this)
186
156
  }
187
157
  }
188
158
 
189
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
190
- handleMenuKeyDown = (event) => {
159
+ handleMenuKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {
191
160
  const key = event && event.keyCode
192
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'pgup' does not exist on type 'CodesMap'.
193
- const { down, up, pgup, pgdn, tab, left } = keycode.codes
161
+ const { down, up, tab, left } = keycode.codes
162
+ const pgdn = keycode.codes['page down']
163
+ const pgup = keycode.codes['page up']
194
164
 
195
165
  if (key === down || key === pgdn) {
196
166
  event.preventDefault()
@@ -212,8 +182,7 @@ class Menu extends Component<MenuProps> {
212
182
  }
213
183
  }
214
184
 
215
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
216
- handleMenuItemSelect = (event, value, selected, item) => {
185
+ handleMenuItemSelect: OnMenuItemSelect = (event, value, selected, item) => {
217
186
  if (this.props.shouldHideOnSelect) {
218
187
  this.hide(event)
219
188
  }
@@ -231,67 +200,56 @@ class Menu extends Component<MenuProps> {
231
200
  this.setState({ hasFocus: this.focusedIndex >= 0 })
232
201
  }
233
202
 
234
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
235
- handleMenuItemMouseOver = (event, menuItem) => {
236
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
203
+ handleMenuItemMouseOver: MenuItemProps['onMouseOver'] = (event, menuItem) => {
237
204
  if (this._activeSubMenu && menuItem !== this._activeSubMenu._trigger) {
238
205
  this.hideActiveSubMenu(event)
239
206
  }
240
207
  }
241
208
 
242
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
243
- hideActiveSubMenu = (event) => {
209
+ hideActiveSubMenu = (event: React.MouseEvent | React.KeyboardEvent) => {
244
210
  if (this._activeSubMenu) {
245
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
246
211
  this._activeSubMenu.hide(event)
247
212
  this._activeSubMenu = null
248
213
  }
249
214
  }
250
215
 
251
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'shown' implicitly has an 'any' type.
252
- handleSubMenuToggle = (shown, subMenu) => {
216
+ handleSubMenuToggle: MenuProps['onToggle'] = (shown, subMenu) => {
253
217
  if (shown) {
254
218
  this._activeSubMenu = subMenu
255
219
  }
256
220
  }
257
221
 
258
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
259
- handleSubMenuDismiss = (event, documentClick) => {
260
- if ((event && event.keyCode === keycode.codes.tab) || documentClick) {
222
+ handleSubMenuDismiss = (
223
+ event: React.MouseEvent | React.KeyboardEvent,
224
+ documentClick: boolean
225
+ ) => {
226
+ if (
227
+ (event && (event as React.KeyboardEvent).keyCode === keycode.codes.tab) ||
228
+ documentClick
229
+ ) {
261
230
  this.hide(event)
262
231
  }
263
232
  }
264
233
 
265
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
266
- hide = (event) => {
234
+ hide = (event: React.MouseEvent | React.KeyboardEvent) => {
267
235
  if (this._popover) {
268
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
269
236
  this._popover.hide(event)
270
237
  }
271
238
  }
272
239
 
273
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
274
- show = (event) => {
240
+ show = (event: React.MouseEvent | React.KeyboardEvent) => {
275
241
  if (this._popover) {
276
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
277
242
  this._popover.show(event)
278
243
  }
279
244
  }
280
245
 
281
246
  focus() {
282
247
  if (this.shown) {
283
- // @ts-expect-error ts-migrate(2555) FIXME: Expected at least 5 arguments, but got 2.
284
- error(this._menu && this._menu.focus, '[Menu] Could not focus the menu.')
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
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
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
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'step' implicitly has an 'any' type.
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
- // @ts-expect-error ts-migrate(2555) FIXME: Expected at least 5 arguments, but got 2.
326
- error(nextItem && nextItem.focus, '[Menu] Could not focus next menu item.')
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
- // @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
365
- child.props['aria-controls'] ||
366
- // @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
367
- child.props.controls ||
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(child as ReactElement, {
377
- controls,
378
- // @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
379
- disabled: disabled || child.props.disabled,
380
- onFocus: this.handleMenuItemFocus,
381
- onBlur: this.handleMenuItemBlur,
382
- onSelect: this.handleMenuItemSelect,
383
- onMouseOver: this.handleMenuItemMouseOver,
384
- tabIndex: isTabbable ? 0 : -1
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
- // @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
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
- // @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
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
- {/* @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'. */}
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
- // @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
448
- const labelledBy = this.props['aria-labelledby'] // eslint-disable-line react/prop-types
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 && this._labelId)}
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
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
502
- onDismiss(event, documentClick)
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
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'el' implicitly has an 'any' type.
527
- ref: (el) => {
528
- this.ref = el
473
+ ref: (el: (React.ReactInstance & { ref?: Element }) | null) => {
474
+ this._trigger = el
475
+ this.ref = el?.ref || (el as Element)
529
476
  },
530
477
  'aria-haspopup': true,
531
478
  id: this._labelId,
532
479
  onMouseOver: this.handleTriggerMouseOver,
533
480
  onKeyDown: this.handleTriggerKeyDown,
534
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'props' does not exist on type 'string | ... Remove this comment to see the full error message
535
- disabled: trigger.props.disabled || disabled
481
+ disabled: (trigger as ReactElement).props.disabled || disabled
536
482
  })}
537
483
  >
538
484
  {this.renderMenu()}