livebook-dev / kino

Client-driven interactive widgets for Livebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kino.Layout.grid hangs forever when you pass another Kino to it

clayscode opened this issue · comments

Kino.Layout.grid(
   Kino.Control.form([
       a: Kino.Input.textarea("hello"), 
       b: Kino.Input.select("Test", [{"a","a"},{"b","b"},{"c","c"}])
    ],
   submit: "Submit")
)

Simple example, but if you run the above code, the cell will just keep evaluating for infinity. Probably using this wrong, but was just looking for a way to control my form's layout.

Mix install:

Mix.install([
  {:kino, "~> 0.12.3"},
])

If you just use input elements without the form, it evaluates fine:

Kino.Layout.grid(
  [Kino.Input.textarea("test"), Kino.Control.button("Submit")]
)

Produces~
Screenshot 2024-03-16 at 8 08 41 PM

Edit: Ah, forget all of that, this works fine:

Kino.Layout.grid(
  [
   Kino.Control.form([
       a: Kino.Input.textarea("hello"), 
       b: Kino.Input.select("Test", [{"a","a"},{"b","b"},{"c","c"}])
    ],
   submit: "Submit")
  ]
)

I just forgot to call grid with a list. Still, shouldn't the correct behavior be to fail for just passing other Kino's?
For instance:

Kino.Layout.grid(
  Kino.Input.textarea("Hello")
)

This hangs forever
Screenshot 2024-03-16 at 8 19 12 PM

Yes, we should raise. The big question is how to do this: should we force it to be a list? Or should we continue to allow any enumerable but explicitly forbidden inputs? I am fine with adding a is_list/1 guard.