mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-09 21:26:05 +08:00
Fix ignored form submissions (#1799)
This commit is contained in:
parent
693ced8430
commit
577a4657c8
7 changed files with 18 additions and 6 deletions
|
|
@ -82,4 +82,16 @@ export function registerGlobalEventHandlers() {
|
||||||
target.dispatchEvent(new Event("click", { bubbles: true }));
|
target.dispatchEvent(new Event("click", { bubbles: true }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ignore submit events on elements with phx-nosubmit
|
||||||
|
window.addEventListener(
|
||||||
|
"submit",
|
||||||
|
(event) => {
|
||||||
|
if (event.target.hasAttribute("phx-nosubmit")) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ capture: true }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ defmodule LivebookWeb.FileSelectComponent do
|
||||||
class="grow"
|
class="grow"
|
||||||
phx-change="set_path"
|
phx-change="set_path"
|
||||||
phx-submit={if @submit_event, do: "submit"}
|
phx-submit={if @submit_event, do: "submit"}
|
||||||
onsubmit={unless @submit_event, do: "return false"}
|
phx-nosubmit={!@submit_event}
|
||||||
phx-target={@myself}
|
phx-target={@myself}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ defmodule LivebookWeb.SessionLive.BinComponent do
|
||||||
<form
|
<form
|
||||||
:if={@bin_entries != []}
|
:if={@bin_entries != []}
|
||||||
phx-change="search"
|
phx-change="search"
|
||||||
onsubmit="return false"
|
phx-nosubmit
|
||||||
phx-target={@myself}
|
phx-target={@myself}
|
||||||
class="mt-1 relative"
|
class="mt-1 relative"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ defmodule LivebookWeb.SessionLive.ExportLiveMarkdownComponent do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="flex flex-col space-y-6">
|
<div class="flex flex-col space-y-6">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<form phx-change="set_options" onsubmit="return false;" phx-target={@myself}>
|
<form phx-change="set_options" phx-nosubmit phx-target={@myself}>
|
||||||
<.switch_field name="include_outputs" label="Include outputs" value={@include_outputs} />
|
<.switch_field name="include_outputs" label="Include outputs" value={@include_outputs} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do
|
||||||
<form
|
<form
|
||||||
phx-change="set_options"
|
phx-change="set_options"
|
||||||
phx-target={@myself}
|
phx-target={@myself}
|
||||||
onsubmit="return false;"
|
phx-nosubmit
|
||||||
class="flex flex-col space-y-4 items-start max-w-full"
|
class="flex flex-col space-y-4 items-start max-w-full"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col space-y-4">
|
<div class="flex flex-col space-y-4">
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ defmodule LivebookWeb.SessionLive.ShortcutsComponent do
|
||||||
you have editor focus and directly modify the given cell content.
|
you have editor focus and directly modify the given cell content.
|
||||||
</p>
|
</p>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<form class="my-2" phx-change="settings" onsubmit="return false;" phx-target={@myself}>
|
<form class="my-2" phx-change="settings" phx-nosubmit phx-target={@myself}>
|
||||||
<.switch_field name="basic" label="Basic view (essential shortcuts only)" value={@basic} />
|
<.switch_field name="basic" label="Basic view (essential shortcuts only)" value={@basic} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ defmodule LivebookWeb.SettingsLive do
|
||||||
<h2 class="text-xl text-gray-800 font-medium pb-2 border-b border-gray-200">
|
<h2 class="text-xl text-gray-800 font-medium pb-2 border-b border-gray-200">
|
||||||
Updates
|
Updates
|
||||||
</h2>
|
</h2>
|
||||||
<form class="mt-4" phx-change="save" onsubmit="return false;">
|
<form class="mt-4" phx-change="save" phx-nosubmit>
|
||||||
<.switch_field
|
<.switch_field
|
||||||
name="update_check_enabled"
|
name="update_check_enabled"
|
||||||
label="Show banner when a new Livebook version is available"
|
label="Show banner when a new Livebook version is available"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue