Skip to content

Form Submit button, Ctrl+Enter, and Shift+Enter all have different behavior #8324

@maxTarlov

Description

@maxTarlov

Describe the bug

If you have a text input inside of a form with clear_on_submit=True, neither Ctrl+Enter nor Shift+Enter trigger the form to clear. Furthermore, Shift+Enter bypasses the form validation callback and form on_change callback. "Submit" runs the text input's on_change handler twice

Image

Will you submit a PR?

  • Yes

Environment

Reproduced in a molab notebook Feb 15, 2026

Details
{
  "marimo": "0.19.11",
  "editable": false,
  "location": "/usr/local/lib/python3.13/site-packages/marimo",
  "OS": "Linux",
  "OS Version": "4.4.0",
  "Processor": "",
  "Python Version": "3.13.11",
  "Locale": "en_US",
  "Binaries": {
    "Browser": "--",
    "Node": "v24.13.1",
    "uv": "0.10.2"
  },
  "Dependencies": {
    "click": "8.3.1",
    "docutils": "0.22.4",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.10.2",
    "narwhals": "2.16.0",
    "packaging": "26.0",
    "psutil": "7.2.2",
    "pygments": "2.19.2",
    "pymdown-extensions": "10.20.1",
    "pyyaml": "6.0.3",
    "starlette": "0.52.1",
    "tomlkit": "0.14.0",
    "typing-extensions": "4.15.0",
    "uvicorn": "0.40.0",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {
    "altair": "6.0.0",
    "anywidget": "0.9.21",
    "duckdb": "1.4.4",
    "loro": "1.10.3",
    "nbformat": "5.10.4",
    "openai": "2.20.0",
    "pandas": "3.0.0",
    "polars": "1.38.1",
    "pyarrow": "23.0.0",
    "pytest": "9.0.2",
    "python-lsp-ruff": "2.3.0",
    "python-lsp-server": "1.14.0",
    "ruff": "0.15.0",
    "sqlglot": "28.6.0"
  },
  "Experimental Flags": {}
}

Code to reproduce

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "marimo>=0.19.11",
# ]
# ///

import marimo

__generated_with = "0.19.11"
app = marimo.App(
    width="medium",
    css_file="/usr/local/_marimo/custom.css",
    auto_download=["html"],
)


@app.cell
def _():
    import marimo as mo

    return (mo,)


@app.cell
def _(mo):
    def _text_change_handler(value):
        print(f"text input changed: {value=}")


    def _form_validate_handler(value):
        print(f"validation callback ran")


    def _form_change_handler(value):
        print(f"form submit callback ran")

    mo.ui.text(full_width=True, on_change=_text_change_handler).form(
        validate=_form_validate_handler, on_change=_form_change_handler, clear_on_submit=True
    )
    return


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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions