Skip to content

Commit 7ea2e9d

Browse files
authored
fix(suite): Fix activity nav item width (#15708)
1 parent 379e7ab commit 7ea2e9d

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

packages/components/src/components/Dropdown/Dropdown.stories.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import React from 'react';
33
import styled from 'styled-components';
44
import { Meta, StoryObj } from '@storybook/react';
55

6-
import { Dropdown as DropdownComponent, DropdownProps } from './Dropdown';
6+
import {
7+
allowedDropdownFrameProps,
8+
Dropdown as DropdownComponent,
9+
DropdownProps,
10+
} from './Dropdown';
11+
import { getFramePropsStory } from '../../utils/frameProps';
712

813
const Center = styled.div`
914
display: flex;
@@ -125,6 +130,7 @@ export const Dropdown: StoryObj<DropdownProps> = {
125130
],
126131
},
127132
],
133+
...getFramePropsStory(allowedDropdownFrameProps).args,
128134
},
129135
argTypes: {
130136
addon: { control: { disable: true } },
@@ -147,5 +153,6 @@ export const Dropdown: StoryObj<DropdownProps> = {
147153
content: { control: { disable: true } },
148154
className: { control: { disable: true } },
149155
coords: { control: { disable: true } },
156+
...getFramePropsStory(allowedDropdownFrameProps).argTypes,
150157
},
151158
};

packages/components/src/components/Dropdown/Dropdown.tsx

+28-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ import { Menu, MenuProps, DropdownMenuItemProps } from './Menu';
2121
import { Coords, getAdjustedCoords } from './getAdjustedCoords';
2222
import { IconButton } from '../buttons/IconButton/IconButton';
2323
import { focusStyleTransition, getFocusShadowStyle } from '../../utils/utils';
24+
import {
25+
FrameProps,
26+
FramePropsKeys,
27+
pickAndPrepareFrameProps,
28+
withFrameProps,
29+
} from '../../utils/frameProps';
30+
import { TransientProps } from '../../utils/transientProps';
31+
32+
export const allowedDropdownFrameProps = ['width'] as const satisfies FramePropsKeys[];
33+
type AllowedFrameProps = Pick<FrameProps, (typeof allowedDropdownFrameProps)[number]>;
2434

2535
const MoreIcon = styled(IconButton)<{ $isToggled: boolean }>`
2636
background: ${({ isDisabled, $isToggled, theme }) =>
@@ -31,7 +41,9 @@ const MoreIcon = styled(IconButton)<{ $isToggled: boolean }>`
3141
}
3242
`;
3343

34-
const Container = styled.div<{ $disabled?: boolean; $hasCustomChildren: boolean }>`
44+
const Container = styled.div<
45+
{ $disabled?: boolean; $hasCustomChildren: boolean } & TransientProps<AllowedFrameProps>
46+
>`
3547
all: unset;
3648
width: fit-content;
3749
height: fit-content;
@@ -40,6 +52,8 @@ const Container = styled.div<{ $disabled?: boolean; $hasCustomChildren: boolean
4052
${getFocusShadowStyle()};
4153
cursor: ${({ $disabled }) => ($disabled ? 'default' : 'pointer')};
4254
55+
${withFrameProps}
56+
4357
${({ $hasCustomChildren }) =>
4458
$hasCustomChildren
4559
? undefined
@@ -75,14 +89,15 @@ const getPlacementData = (
7589
return { coordsToUse, toggleDimensions };
7690
};
7791

78-
export type DropdownProps = Omit<MenuProps, 'setToggled'> & {
79-
isDisabled?: boolean;
80-
renderOnClickPosition?: boolean;
81-
onToggle?: (isToggled: boolean) => void;
82-
className?: string;
83-
'data-testid'?: string;
84-
children?: ((isToggled: boolean) => ReactElement<any>) | ReactElement<any>;
85-
};
92+
export type DropdownProps = Omit<MenuProps, 'setToggled'> &
93+
AllowedFrameProps & {
94+
isDisabled?: boolean;
95+
renderOnClickPosition?: boolean;
96+
onToggle?: (isToggled: boolean) => void;
97+
className?: string;
98+
'data-testid'?: string;
99+
children?: ((isToggled: boolean) => ReactElement<any>) | ReactElement<any>;
100+
};
86101

87102
export interface DropdownRef {
88103
close: () => void;
@@ -106,6 +121,7 @@ export const Dropdown = forwardRef(
106121
className,
107122
children,
108123
'data-testid': dataTest,
124+
...rest
109125
}: DropdownProps,
110126
ref,
111127
) => {
@@ -230,6 +246,8 @@ export const Dropdown = forwardRef(
230246
document.body,
231247
);
232248

249+
const frameProps = pickAndPrepareFrameProps(rest, allowedDropdownFrameProps);
250+
233251
return (
234252
<Container
235253
ref={toggleRef}
@@ -240,6 +258,7 @@ export const Dropdown = forwardRef(
240258
onFocus={() => !isDisabled && !renderOnClickPosition && setToggled(true)}
241259
onBlur={e => !menuRef.current?.contains(e.relatedTarget) && setToggled(false)}
242260
$hasCustomChildren={hasCustomChildren}
261+
{...frameProps}
243262
>
244263
{ToggleComponent}
245264
{isToggled && PortalMenu}

packages/suite/src/components/suite/layouts/SuiteLayout/Sidebar/NotificationDropdown.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const NotificationDropdown = (props: NavigationItemProps) => {
5454
<Notifications onCancel={() => dropdownRef.current!.close()} />
5555
</Box>
5656
}
57+
width="100%"
5758
>
5859
{isToggled => <StyledNavigationItem {...props} isActive={isToggled} />}
5960
</Dropdown>

0 commit comments

Comments
 (0)