Skip to content

Commit abe6e50

Browse files
feat: display icon if there is only one actions menu
1 parent 267a6a5 commit abe6e50

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

packages/ui/src/Page/ToolbarActions.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,31 @@ export const ToolbarActions = ({ actions }: ToolbarActionsMenuProperties) => {
2222
return null;
2323
}
2424

25-
const { icon, label, onClick, disabled, ...rest } = actions[0];
26-
27-
if (actions.length == 1 && icon) {
25+
if (actions.length > 1) {
2826
return (
29-
<Button
30-
variant="textOnly"
31-
iconLeft={icon}
32-
data-pr-tooltip={label}
33-
onClick={onClick}
34-
rounded
35-
{...rest}
27+
<DropdownMenu
28+
label={
29+
<Button iconLeft="pi pi-cog" size="medium" variant="outlined" />
30+
}
31+
menu={actions}
32+
hideDropdownIcon
3633
/>
3734
);
3835
}
3936

37+
const [{ icon, iconLeft, iconRight, label, onClick, disabled, ...rest }] =
38+
actions;
39+
40+
const buttonIcon = icon ?? iconLeft ?? iconRight;
41+
4042
return (
41-
<DropdownMenu
42-
label={<Button iconLeft="pi pi-cog" size="medium" variant="outlined" />}
43-
menu={actions}
44-
hideDropdownIcon
43+
<Button
44+
variant="textOnly"
45+
iconLeft={buttonIcon}
46+
data-pr-tooltip={label}
47+
onClick={onClick}
48+
rounded
49+
{...rest}
4550
/>
4651
);
4752
};

0 commit comments

Comments
 (0)