Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customer_data_app: Form submission canceled because the form is not connected #253

Open
hkws opened this issue Aug 14, 2024 · 0 comments
Open

Comments

@hkws
Copy link

hkws commented Aug 14, 2024

When the rx.dialog.close component, which has a button with type=submit as its child, is clicked, the dialog successfully closes, but the form submission is canceled. The following message appears in the browser console:

Form submission canceled because the form is not connected

Current Behavior

  • The on_submit event handler is not executed when the submit button is used within rx.dialog.close.

Expected Behavior

  • The on_submit event handler should be executed when the submit button is used within rx.dialog.close.

Reproducible Example

  • https://customer-data-app.reflex.run/
    • Click Add Customer.
    • Fill out the form.
    • Click Submit Customer.
    • The above message appears in the browser console.
  • Below is the minimum reproducible code:
import reflex as rx

def ng() -> rx.Component:
    return rx.dialog.root(
        rx.dialog.trigger(
            rx.button(
                rx.text("Add"),
            ),
        ),
        rx.dialog.content(
            rx.dialog.title(
                "Add New Item",
            ),
            rx.dialog.description(
                "Fill the form with the item's info",
            ),
            rx.form.root(
                rx.radio(
                    ["a", "b", "c"],
                    name="status",
                    direction="row",
                    as_child=True,
                    required=True,
                ),
                rx.form.submit(
                    rx.dialog.close(
                        rx.button("Submit"),
                    ),
                    as_child=True,
                ),
                on_submit=rx.console_log("on_submit fired!"),
            ),
        ),
    )


def ok() -> rx.Component:
    return rx.dialog.root(
        rx.dialog.trigger(
            rx.button(
                rx.text("Add"),
            ),
        ),
        rx.dialog.content(
            rx.dialog.title(
                "Add New Item",
            ),
            rx.dialog.description(
                "Fill the form with the item's info",
            ),
            rx.form.root(
                rx.radio(
                    ["a", "b", "c"],
                    name="status",
                    direction="row",
                    as_child=True,
                    required=True,
                ),
                rx.form.submit(
                    rx.button("Submit"),
                    as_child=True,
                ),
                on_submit=rx.console_log("on_submit fired!"),
            ),
        ),
    )


app = rx.App()

app.add_page(ok, route="/ok")
app.add_page(ng, route="/ng")

Suggested Solution

Environment

  • Python Version: 3.12.4
  • Reflex Version: 0.5.9
  • OS: macOS Sonoma v14.5
  • Browser (Optional): Chrome 127.0.6533.100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant