ztawil
ztawil•9mo ago

Submit button not triggering

Have we seen anything where the "submit" button on a form isn't updating the values of the input form in app mode? I have an app and when I'm in the app view, the submit button doesn't seem to be updating the values for the inputs. However, when I switch from app view to code editor, the submit button works
11 Replies
Akshay
Akshay•9mo ago
Strange, I haven't seen that before. Any chance you can share code that reproduces the issue?
ztawil
ztawilOP•9mo ago
Let me see, the notebook I have working on is pretty indepth with local code. Let me try to reproduce with a simpler notebook
ztawil
ztawilOP•9mo ago
ztawil
ztawilOP•9mo ago
In the meantime, here's a screen recording if that helps
Akshay
Akshay•9mo ago
hmm interesting. what version of marimo? it's really weird that it works when you toggle to edit mode and then back ... Can you try something? Where you output form.value, instead of making it the output of the cell, can you use Python print? print(form.value). Then see if in the preview mode whether the correct value is printed? I'm curious if this is a frontend issue or backend issue
ztawil
ztawilOP•9mo ago
ztawil
ztawilOP•9mo ago
I could recreate with this print(input_form.value) gives the old value
Akshay
Akshay•9mo ago
That's helpful, thanks! I can take a look
ztawil
ztawilOP•9mo ago
🫶
$ pip freeze | grep marimo
marimo==0.2.8
$ pip freeze | grep marimo
marimo==0.2.8
Akshay
Akshay•9mo ago
I think there's some state in the frontend that doesn't get updated. Switching from edit to run mode or vice versa "fixes" it because the form component gets unmounted which clears the form state as a side effect Got a pretty minimal repro. Thanks for bringing this to our attention.
import marimo

__generated_with = "0.2.8"
app = marimo.App()


@app.cell
def __():
import marimo as mo
return mo,


@app.cell
def __(mo):
mo.md("Modify the below text input to re-render the form, then hit submit")
return


@app.cell
def __(mo):
input = mo.ui.text()
input
return input,


@app.cell
def __(input, mo):
input_form = mo.ui.text(value=input.value).form()
input_form
return input_form,


@app.cell
def __(input_form):
input_form.value
return


if __name__ == "__main__":
app.run()
import marimo

__generated_with = "0.2.8"
app = marimo.App()


@app.cell
def __():
import marimo as mo
return mo,


@app.cell
def __(mo):
mo.md("Modify the below text input to re-render the form, then hit submit")
return


@app.cell
def __(mo):
input = mo.ui.text()
input
return input,


@app.cell
def __(input, mo):
input_form = mo.ui.text(value=input.value).form()
input_form
return input_form,


@app.cell
def __(input_form):
input_form.value
return


if __name__ == "__main__":
app.run()
Just put out a PR that should fix this issue, will let you know when a fix is merged and released
ztawil
ztawilOP•9mo ago
Thanks @Akshay