Skip to content

Commit

Permalink
feat: 🎸 [Table] Global actions callback to use undefined data
Browse files Browse the repository at this point in the history
Actions of type 'icon' or 'toolbar' will execute callback passing
undefined data
  • Loading branch information
luciob committed Mar 22, 2022
1 parent e46417a commit 60b82ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Table/components/ToolbarAction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const TableToolbarAction: FC<ITableToolbarAction> = ({

const style = useMemo((): CSSProperties => ({ marginLeft: index > 0 ? "8px" : "none" }), [index]);

const onClick = useCallback(() => callback(data, dataCallbackOptions), [callback, data, dataCallbackOptions]);
const global = useMemo(() => position === "icon" || position === "toolbar", [position]);

const onClick = useCallback(
() => callback(!global ? data : undefined, dataCallbackOptions),
[callback, data, dataCallbackOptions, global]
);

if (secondary) {
return (
Expand Down

0 comments on commit 60b82ae

Please sign in to comment.