diff --git a/elixir/apps/web/lib/web/live_table.ex b/elixir/apps/web/lib/web/live_table.ex index 4a36e3436..48fb08fb8 100644 --- a/elixir/apps/web/lib/web/live_table.ex +++ b/elixir/apps/web/lib/web/live_table.ex @@ -97,6 +97,7 @@ defmodule Web.LiveTable do for={@form} phx-change="filter" phx-debounce="100" + onkeydown="return event.key != 'Enter';" > <.input type="hidden" name="table_id" value={@live_table_id} /> diff --git a/elixir/apps/web/test/web/live/groups/index_test.exs b/elixir/apps/web/test/web/live/groups/index_test.exs index c3dc3eac0..6edb1c79b 100644 --- a/elixir/apps/web/test/web/live/groups/index_test.exs +++ b/elixir/apps/web/test/web/live/groups/index_test.exs @@ -52,6 +52,20 @@ defmodule Web.Live.Groups.IndexTest do assert Floki.text(button) =~ "Add Group" end + test "filters form has onkeydown attribute to prevent Enter from submitting form", %{ + account: account, + identity: identity, + conn: conn + } do + {:ok, _lv, html} = + conn + |> authorize_conn(identity) + |> live(~p"/#{account}/groups") + + assert form = Floki.find(html, "form#groups-filters") + assert ["return event.key != 'Enter';"] = Floki.attribute(form, "onkeydown") + end + test "renders empty table when there are no groups", %{ account: account, identity: identity,