fasthtml icon indicating copy to clipboard operation
fasthtml copied to clipboard

[BUG] Pico Search component doesn't work as expected

Open StanleyTack opened this issue 1 year ago • 2 comments

Describe the bug Using the Pico Search component does not reproduce UI elements like in teh pico docs https://picocss.com/docs/group#search

Minimal Reproducible Example

from fasthtml.common import *
app, rt = fast_app(
    hdrs=(picolink,),
)
def search_form():
    return Search(
        Input(name="search", type="search", placeholder="search"),
        Input(type="submit", value="search"),cls="container")

result:

<search class="container">       
       <input name="search" type="search" placeholder="search">
       <input type="submit" value="search">
</search>

image

Expected behavior Expected: image

Visually, the textbox has the correct style but the submit button does not. Expected html per picocss docs

<form role="search">
  <input name="search" type="search" placeholder="Search" />
  <input type="submit" value="Search" />
</form>

Environment Information Please provide the following version information:

  • fastlite version: 0.0.11
  • fastcore version: 1.7.10
  • fasthtml version: 0.6.9

Confirmation Please confirm the following:

  • [x] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • [x] I have provided a minimal reproducible example
  • [x] I have included the versions of fastlite, fastcore, and fasthtml
  • [x] I understand that this is a volunteer open source project with no commercial support.

Additional context Add any other context about the problem here.

Screenshots If applicable, add screenshots to help explain your problem.

StanleyTack avatar Sep 30 '24 17:09 StanleyTack

Workaround:

  • use a Group instead of Search.
  • then instead of Input with type=Submit, use a Button with type=Submit and role=Search
  • also need to wrap the Group in a Form to make it a form
search_form = Form(method="get", action="/", id="search-form")(
        Group(
            Input(type="search", name="search", placeholder="search", value=search_query),
            Button("Search", type="submit", role="search"),
        ),
    )

result HTML:

<form enctype="multipart/form-data" method="get" action="/" id="search-form" name="search-form">
     <fieldset role="group">
           <input type="search" name="search" placeholder="search">
           <button type="submit" role="search">Search</button>
     </fieldset>
</form>

StanleyTack avatar Oct 03 '24 16:10 StanleyTack

I just validated this error here, while also confirming that other fasthml.components work:

from fasthtml.common import *
from fasthtml.components import Search

app, rt = fast_app()

@rt
def index():
    return Titled("Search",
        co.Search(Input(type="search"), Button("Search")),
        Grid(Div('one'), Div('2'))
    )

serve()

pydanny avatar Oct 07 '24 13:10 pydanny