Skip to content

Commit

Permalink
Reset pagination on sorting (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristineguadelupe authored Oct 11, 2023
1 parent 2fe6d86 commit 7be7ce6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/kino/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ defmodule Kino.Table do
end

def handle_event("order_by", %{"key" => nil}, ctx) do
{:noreply, ctx |> assign(order: nil) |> broadcast_update()}
{:noreply, ctx |> assign(order: nil, page: 1) |> broadcast_update()}
end

def handle_event("order_by", %{"key" => key_string, "direction" => direction}, ctx) do
direction = String.to_existing_atom(direction)
key = lookup_key(ctx, key_string)
ctx = if key, do: assign(ctx, order: %{key: key, direction: direction}), else: ctx
ctx = if key, do: assign(ctx, order: %{key: key, direction: direction}, page: 1), else: ctx
{:noreply, broadcast_update(ctx)}
end

Expand Down

0 comments on commit 7be7ce6

Please sign in to comment.