You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
Can you explain to me exactly how this button works? I need to clear the SearchBar.value in my own function, I mean to set an empty string, but it doesn't update visually, only if I set an empty string with one space, like " ", or some other text.
Code sample
importfletasftdefmain(page):
defclose_anchor(e):
text=f"Item {e.control.data}"print(f"closing view from {text}")
anchor.close_view(text)
defhandle_tap(e):
e.control.open_view()
defclean_function(e):
anchor.value=""#This doesn't work.# anchor.value = " " # This works and updates visually.# anchor.value = "Some text" # And this as well.anchor.update()
anchor=ft.SearchBar(
view_elevation=4,
divider_color=ft.colors.AMBER,
bar_hint_text="Test searchbar",
view_hint_text="Choose something from the suggestions...",
on_tap=handle_tap,
controls=[
ft.ListTile(title=ft.Text(f"Item {i}"), on_click=close_anchor, data=i)
foriinrange(10)
],
)
clean_button=ft.ElevatedButton(text="Clear")
page.add(
ft.Row(
alignment=ft.MainAxisAlignment.CENTER,
controls=[
ft.OutlinedButton(
"Clear searchbar textfield",
on_click=clean_function,
),
],
),
anchor,
)
ft.app(target=main)
Discussed in #3869
Originally posted by Katsiuk August 25, 2024
Question
Hello!
Can you explain to me exactly how this button works? I need to clear the SearchBar.value in my own function, I mean to set an empty string, but it doesn't update visually, only if I set an empty string with one space, like " ", or some other text.
Code sample
Error message
No response
------------------------------------------------------
The text was updated successfully, but these errors were encountered: