mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-13 08:24:22 +08:00
Fix input value lookup for nested inputs (#1537)
This commit is contained in:
parent
ce93015a0d
commit
16d473685a
2 changed files with 21 additions and 1 deletions
|
@ -1018,8 +1018,10 @@ defmodule Livebook.Session.Data do
|
|||
end
|
||||
|
||||
defp add_cell_output({data, _} = data_actions, cell, output) do
|
||||
{[indexed_output], _counter} = Notebook.index_outputs([output], 0)
|
||||
|
||||
new_input_values =
|
||||
{0, output}
|
||||
indexed_output
|
||||
|> Cell.find_inputs_in_output()
|
||||
|> Map.new(fn attrs -> {attrs.id, attrs.default} end)
|
||||
|
||||
|
|
|
@ -2236,6 +2236,24 @@ defmodule Livebook.Session.DataTest do
|
|||
assert {:ok, %{input_values: %{"i1" => "hey"}}, _} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "stores default values for new nested inputs" do
|
||||
input = %{id: "i1", type: :text, label: "Text", default: "hey"}
|
||||
output = {:grid, [{:input, input}], %{}}
|
||||
|
||||
data =
|
||||
data_after_operations!([
|
||||
{:insert_section, @cid, 0, "s1"},
|
||||
{:insert_cell, @cid, "s1", 0, :code, "c1", %{}},
|
||||
{:set_runtime, @cid, connected_noop_runtime()},
|
||||
evaluate_cells_operations(["setup"]),
|
||||
{:queue_cells_evaluation, @cid, ["c1"]}
|
||||
])
|
||||
|
||||
operation = {:add_cell_evaluation_response, @cid, "c1", output, eval_meta()}
|
||||
|
||||
assert {:ok, %{input_values: %{"i1" => "hey"}}, _} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "keeps input values for inputs that existed" do
|
||||
input = %{id: "i1", type: :text, label: "Text", default: "hey"}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue