Skip to content

Commit 12aaee9

Browse files
committed
Make tooltip text available as function as well.
1 parent fc7c40c commit 12aaee9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/components/table/header/actions/action.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const HeaderAction = forwardRef(
1616
table,
1717
tooltipText,
1818
alwaysEnabled,
19+
disabledTooltipText,
1920
...rest
2021
},
2122
ref
@@ -37,6 +38,11 @@ const HeaderAction = forwardRef(
3738
disabled={(!alwaysEnabled && selectedRows?.length < 1) || disabled}
3839
background="elementBackground"
3940
selectedRows={selectedRows}
41+
disabledTooltipText={
42+
typeof disabledTooltipText === "function"
43+
? disabledTooltipText(selectedRows)
44+
: disabledTooltipText
45+
}
4046
{...rest}
4147
/>
4248
)

src/components/table/useColumns/useRowActions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,25 @@ export default (rowActions, { testPrefix, tableMeta } = {}) => {
7272
cell: ({ row, table }) => (
7373
<Flex data-testid="action-cell" height="100%" gap={2} justifyContent="end">
7474
{availableRowActions.map(
75-
({ id, handleAction, isDisabled, isVisible = true, dataGa, ...rest }) => (
75+
({
76+
id,
77+
handleAction,
78+
isDisabled,
79+
isVisible = true,
80+
dataGa,
81+
disabledTooltipText,
82+
...rest
83+
}) => (
7684
<Action
7785
{...rest}
7886
disabled={typeof isDisabled === "function" ? isDisabled(row.original) : isDisabled}
7987
visible={typeof isVisible === "function" ? isVisible(row.original) : isVisible}
8088
dataGa={typeof dataGa === "function" ? dataGa(row.original) : dataGa}
89+
disabledTooltipText={
90+
typeof disabledTooltipText === "function"
91+
? disabledTooltipText(row.original)
92+
: disabledTooltipText
93+
}
8194
key={id}
8295
id={id}
8396
handleAction={() => handleAction(row.original, table)}

0 commit comments

Comments
 (0)