11/**
2- * Copyright IBM Corp. 2016, 2023
2+ * Copyright IBM Corp. 2016, 2025
33 *
44 * This source code is licensed under the Apache-2.0 license found in the
55 * LICENSE file in the root directory of this source tree.
66 */
77
8- import FloatingMenu , {
8+ import {
99 DIRECTION_BOTTOM ,
1010 DIRECTION_TOP ,
11+ FloatingMenu ,
12+ type MenuDirection ,
13+ type MenuOffset ,
1114} from '../../internal/FloatingMenu' ;
1215import React , { ComponentType } from 'react' ;
1316import { matches as keyCodeMatches , keys } from '../../internal/keyboard' ;
@@ -54,13 +57,12 @@ const triggerButtonPositionFactors = {
5457 [ DIRECTION_BOTTOM ] : - 1 ,
5558} ;
5659
57- /**
58- * @param {Element } menuBody The menu body with the menu arrow.
59- * @param {string } direction The floating menu direction.
60- * @returns {FloatingMenu~offset } The adjustment of the floating menu position, upon the position of the menu arrow.
61- * @private
62- */
63- export const getMenuOffset = ( menuBody , direction , trigger , flip ) => {
60+ export const getMenuOffset : MenuOffset = (
61+ menuBody ,
62+ direction ,
63+ trigger ,
64+ flip
65+ ) => {
6466 const triggerButtonPositionProp = triggerButtonPositionProps [ direction ] ;
6567 const triggerButtonPositionFactor = triggerButtonPositionFactors [ direction ] ;
6668 if ( __DEV__ ) {
@@ -82,17 +84,11 @@ export const getMenuOffset = (menuBody, direction, trigger, flip) => {
8284 top : 0 ,
8385 } ;
8486 }
85-
8687 default :
87- break ;
88+ return { left : 0 , top : 0 } ;
8889 }
8990} ;
9091
91- interface Offset {
92- top ?: number | null | undefined ;
93- left ?: number | null | undefined ;
94- }
95-
9692type IconProps = {
9793 className ?: string ;
9894 'aria-label' ?: string ;
@@ -124,7 +120,7 @@ export interface OverflowMenuProps {
124120 /**
125121 * The menu direction.
126122 */
127- direction ?: string ;
123+ direction ?: MenuDirection ;
128124
129125 /**
130126 * `true` if the menu alignment should be flipped.
@@ -160,12 +156,12 @@ export interface OverflowMenuProps {
160156 /**
161157 * The adjustment in position applied to the floating menu.
162158 */
163- menuOffset ?: Offset | ( ( ) => void ) ;
159+ menuOffset ?: MenuOffset ;
164160
165161 /**
166162 * The adjustment in position applied to the floating menu.
167163 */
168- menuOffsetFlip ?: Offset | ( ( ) => void ) ;
164+ menuOffsetFlip ?: MenuOffset ;
169165
170166 /**
171167 * The class to apply to the menu options
@@ -391,10 +387,10 @@ class OverflowMenu extends React.Component<
391387
392388 /**
393389 * The element ref of the tooltip's trigger button.
394- * @type {React.RefObject<Element > }
390+ * @type {React.RefObject<HTMLElement > }
395391 * @private
396392 */
397- _triggerRef = React . createRef ( ) ;
393+ _triggerRef = React . createRef < HTMLElement > ( ) ;
398394
399395 componentDidUpdate ( _ , prevState ) {
400396 const { onClose = noopFn } = this . props ;
0 commit comments