fix(ux): Prevent <Enter> from submitting filters forms (#5213)

Fixes #5211
This commit is contained in:
Jamil
2024-06-06 05:48:38 -07:00
committed by GitHub
parent 9db3518e76
commit bafa9e0625
2 changed files with 15 additions and 0 deletions

View File

@@ -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} />

View File

@@ -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,