Skip to content

Issue closing Modal after request submission #61

@seekerquest

Description

@seekerquest

Hi,

I'm having an issue with Dialog component closing without removing the backdrop. the backdrop div element is added every time the Dialog trigger is clicked the element is further remove after clicking away, but in situations where i need to submit a form to the backend and close Dialog this doesn't happen, the Dialog is closed but leaves behind a backdrop. wondering if there is a better way of handling this using request/response behavior. here is an example:

Dialog(
        Form(
            Fieldset(
                Div(
                    Label("Role Name", htmlFor="role_name"),
                    Input(id="role_name", name="name", type="text", required=True, cls="w-full"),
                    cls="mb-4"
                ),
                Div(
                    Label("Description", htmlFor="description"),
                    Textarea(id="description", name="description", required=True, cls="w-full"),
                    cls="mb-4"
                ),
                Div(
                    Label("Permissions", htmlFor="permissions"),
                    ShadGrid(
                        permissions,
                    ),
                    cls="mb-4"
                ),
                Button(
                    "Add Role", 
                    type="submit",
                    cls="w-full my-2",
                ),
                cls="p-4"
            ),
            
            hx_post="/roles/add",
            hx_target="#addRoleModal",
            hx_swap="outerHTML",
            hx_trigger="click",
        ),
        trigger=Button(Lucide(icon="plus"), variant=variant, size=size, data_ref="dialog-trigger"),
        title="Add Role",
        description="Enter the role details to add a new role.",
        id="addRoleModal",
    )

Thank you for your help and further for this great library, it allows building UIs much faster.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions