Update :debounce default fallback for range input

This commit is contained in:
Jonatan Kłosko 2023-10-06 14:01:39 +07:00
parent e2abc760a4
commit 706eb42dc0
2 changed files with 8 additions and 2 deletions

View file

@ -341,7 +341,7 @@ defprotocol Livebook.Runtime do
type: :range,
default: number(),
label: String.t(),
debounce: :blur | non_neg_integer(),
debounce: non_neg_integer(),
min: number(),
max: number(),
step: number()

View file

@ -2892,7 +2892,13 @@ defmodule Livebook.Session do
defp normalize_runtime_output(%{type: :input, attrs: attrs} = output)
when attrs.type in [:text, :textarea, :password, :number, :url, :range, :color] and
not is_map_key(attrs, :debounce) do
put_in(output.attrs[:debounce], :blur)
default =
case attrs.type do
:range -> 250
_other -> :blur
end
put_in(output.attrs[:debounce], default)
|> normalize_runtime_output()
end