Skip to content

monsterui Select not working when a switch or checkbox is present #91

@oegedijk

Description

@oegedijk

Sorry to bother you again :) The mui.Select and fh.Select are still not equivalent when there is e.g. a switch or a checkbox present, the Select value is not passed with mui.Select but it is passed with fh.Select:

import monsterui.all as mui
from fasthtml.common import *

# app, rt = fast_app()

hdrs = mui.Theme.blue.headers()
app, rt = fast_app(hdrs=hdrs)


@rt("/")
def get_index():
    return Div(
        Form(
            CheckboxX(
                checked=True,
                label="Toggle",
                id="toggle",
                name="toggle",
                hx_get="/example",
                hx_target="#example-content",
                hx_swap="innerHTML",
                hx_include="#example_selector",
            ),
            mui.Select( # this does not work
                # Select( # this works
                Option("Option 1", value="1"),
                Option("Option 2", value="2"),
                Option("Option 3", value="3"),
                id="example_selector",
                hx_get="/example",
                hx_target="#example-content",
                hx_trigger="change",
                hx_swap="innerHTML",
                hx_include="#toggle",
                name="example_id",
            ),
            id="example-form",
        ),
        Div(id="example-content"),
    )


@rt("/example", methods=["GET"])
def get_example(example_id: str = "not selected", toggle: bool = False):
    return Div(
        f"Example content for option {example_id} and {toggle}",
    )


serve()

result with fh.Select:

Image

result with mui.Select:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions