Skip to content

Commit 9f8fea1

Browse files
yash-rajpaldougfabrisjuliajforesti
authored
fix(fuselage): MenuV2 not handling focus properly (#1632)
Co-authored-by: Douglas Fabris <devfabris@gmail.com> Co-authored-by: juliajforesti <juliajforesti@gmail.com>
1 parent 5c8eff6 commit 9f8fea1

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

.changeset/loose-teams-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/fuselage': patch
3+
---
4+
5+
fix(fuselage): `MenuV2` not handling focus properly

packages/fuselage/src/components/Dropdown/DropdownDesktop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const DropdownDesktop = forwardRef(function DropdownDesktop<
3131
{...props}
3232
>
3333
<Box flexShrink={1} pb={12}>
34-
{(style as any).visibility === 'hidden' ? null : children}
34+
{style?.visibility === 'hidden' ? null : children}
3535
</Box>
3636
</Tile>
3737
);
Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { useBreakpoints } from '@rocket.chat/fuselage-hooks';
22
import type { ReactNode } from 'react';
3-
import { useRef } from 'react';
43
import type { AriaPopoverProps } from 'react-aria';
5-
import { usePopover } from 'react-aria';
64
import type { OverlayTriggerState } from 'react-stately';
75

86
import { DropdownDesktop } from '../../Dropdown/DropdownDesktop';
97
import { DropdownMobile } from '../../Dropdown/DropdownMobile';
8+
import { Popover } from '../../Popover';
109

11-
interface PopoverProps extends Omit<AriaPopoverProps, 'popoverRef'> {
10+
interface MenuPopoverProps extends Omit<AriaPopoverProps, 'popoverRef'> {
1211
children: ReactNode;
1312
state: OverlayTriggerState;
1413
maxWidth?: string;
@@ -20,32 +19,21 @@ function MenuPopover({
2019
offset = 4,
2120
maxWidth,
2221
...props
23-
}: PopoverProps) {
24-
const popoverRef = useRef(null);
25-
const { popoverProps } = usePopover(
26-
{
27-
...props,
28-
offset,
29-
popoverRef,
30-
},
31-
state,
32-
);
33-
34-
const breakpoints = useBreakpoints();
35-
const isMobile = !breakpoints.includes('sm');
22+
}: MenuPopoverProps) {
23+
const isMobile = !useBreakpoints().includes('sm');
3624

3725
if (isMobile) {
38-
const mobileProps = { ...popoverProps, style: { bottom: 0, left: 0 } };
39-
return <DropdownMobile children={children} {...mobileProps} />;
26+
return (
27+
<Popover state={state} offset={offset} {...props}>
28+
<DropdownMobile>{children}</DropdownMobile>
29+
</Popover>
30+
);
4031
}
4132

4233
return (
43-
<DropdownDesktop
44-
children={children}
45-
ref={popoverRef}
46-
maxWidth={maxWidth}
47-
{...popoverProps}
48-
/>
34+
<Popover state={state} offset={offset} {...props}>
35+
<DropdownDesktop maxWidth={maxWidth}>{children}</DropdownDesktop>
36+
</Popover>
4937
);
5038
}
5139
export default MenuPopover;

0 commit comments

Comments
 (0)