Skip to content

Commit

Permalink
use native on click handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingjam committed Feb 17, 2025
1 parent cf00fcb commit 3630267
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{/if}

<Refresh
onClick={() =>
on:click={() =>
queryClient.invalidateQueries({
queryKey: [id],
refetchType: 'all',
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-components/src/__tests__/TanstackAppTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ test('shows refresh icon', async () => {

resolve();

await waitFor(() => expect(screen.getByTestId('refresh-button')).toBeInTheDocument());
await waitFor(() => expect(screen.getByTestId('refreshButton')).toBeInTheDocument());
});

test('refetches data when refresh button is clicked', async () => {
Expand All @@ -170,7 +170,7 @@ test('refetches data when refresh button is clicked', async () => {
head: 'Test head'
});

const refreshButton = screen.getByTestId('refresh-button');
const refreshButton = screen.getByTestId('refreshButton');
await userEvent.click(refreshButton);

expect(mockRefetch).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<slot name="title" />
<Refresh
class="ml-2 h-8 w-5 cursor-pointer text-gray-400 dark:text-gray-400"
data-testid="refreshButton"
spin={$query.isLoading || $query.isFetching}
onClick={() => {
on:click={() => {
$query.refetch();
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
</Button>
{/if}
<Refresh
onClick={() =>
on:click={() =>
queryClient.invalidateQueries({
queryKey: [id],
refetchType: 'all',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<span></span>
<Refresh
class="h-8 w-5 cursor-pointer text-gray-400 dark:text-gray-400"
onClick={refreshQuotes}
on:click={refreshQuotes}
spin={$orderQuoteQuery.isLoading || $orderQuoteQuery.isFetching}
/>
<PauseSolid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
{/if}

<Refresh
onClick={() =>
on:click={() =>
queryClient.invalidateQueries({
queryKey: [id],
refetchType: 'all',
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-components/src/lib/components/icon/Refresh.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
export let role = ctx.role || 'img';
export let ariaLabel = 'refresh';
export let spin = false;
export let onClick: () => void;
</script>

<svg
data-testid="refresh-button"
on:click={onClick}
xmlns="http://www.w3.org/2000/svg"
fill="none"
{...$$restProps}
Expand Down

0 comments on commit 3630267

Please sign in to comment.