File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,18 @@ export const KebabMenu: React.FC<KebabMenuProps> = ({ items, className }) => {
3434
3535 // Calculate dropdown position when menu opens
3636 useEffect ( ( ) => {
37- if ( isOpen && buttonRef . current ) {
38- const rect = buttonRef . current . getBoundingClientRect ( ) ;
39- setDropdownPosition ( {
40- top : rect . bottom + 4 , // 4px gap below button
41- left : rect . right - 160 , // Align right edge (160px = min-width)
42- } ) ;
43- }
37+ if ( ! isOpen || ! buttonRef . current ) return ;
38+
39+ const rect = buttonRef . current . getBoundingClientRect ( ) ;
40+ const nextPosition = {
41+ top : rect . bottom + 4 , // 4px gap below button
42+ left : rect . right - 160 , // Align right edge (160px = min-width)
43+ } ;
44+
45+ // Only update when position actually changes to avoid render loops
46+ setDropdownPosition ( ( prev ) =>
47+ prev . top === nextPosition . top && prev . left === nextPosition . left ? prev : nextPosition
48+ ) ;
4449 } , [ isOpen ] ) ;
4550
4651 // Close menu when clicking outside
You can’t perform that action at this time.
0 commit comments