Skip to content

Commit

Permalink
Updated AutoButton type to accept non-string children
Browse files Browse the repository at this point in the history
  • Loading branch information
MillanWangGadget committed Nov 6, 2024
1 parent 798fe22 commit e77236b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/react/.changeset/famous-garlics-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gadgetinc/react": patch
---

Updated AutoButton type to accept non-string children
4 changes: 3 additions & 1 deletion packages/react/src/auto/polaris/PolarisAutoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const PolarisAutoButton = <
SchemaT,
ActionFunc extends ActionFunction<GivenOptions, any, any, SchemaT, any> | GlobalActionFunction<any>
>(
props: AutoButtonProps<GivenOptions, SchemaT, ActionFunc> & ComponentProps<typeof Button>
props: AutoButtonProps<GivenOptions, SchemaT, ActionFunc> &
Omit<ComponentProps<typeof Button>, "children"> & { children?: React.ReactNode }
) => {
const { fetching, running, isDestructive, run, label, buttonProps } = useAutoButtonController({
onSuccess: (_result) => {
Expand All @@ -38,6 +39,7 @@ export const PolarisAutoButton = <

return (
<Button loading={running} disabled={fetching} tone={isDestructive ? "critical" : undefined} onClick={run} {...buttonProps}>
{/* @ts-expect-error // Polaris Button children types demands strings, but ReactComponents work*/}
{props?.children ?? label}
</Button>
);
Expand Down

0 comments on commit e77236b

Please sign in to comment.