Closed mfxbe closed 2 months ago
Sorry for that, we forgot to mention a change in this Control. From now on, the dev (you) is responsible for opening the searchbar when it is pressed. (ref)
Briefly: you just need to call search_bar.open_view()
in your on_tap
event handler
Will update documentation code.
Thank you for your answer and the hint with the tab_handler. But I'm still not completely sure how I should solve it.
As you can see in the code example above I use a class to build a "widget" based on the SearchBar. If I put self.on_tap = self.open_view()
in there it leads to the following issue:
AssertionError: Control must be added to the page first.
I would really prefer not to be forced to set up that event handler for each instance but I see no way to do that here. Am I missing something?
Update:
For now I managed to bypass the problem by setting self.on_change = self.handle_change
and adding this function within the class:
def handle_tap(self, _e):
if self.page is not None: self.open_view()
adding this function within the class:
Yep! As I said, the only change is to call that method in the on_tap
handler.
If I put
self.on_tap = self.open_view()
in there it leads to the following issue: AssertionError: Control must be added to the page first.
You are not doing it right, that's why it fails.
You could have done it like this Instead: self.on_tap = lambda e: self.open_view()
, or you create a method for the on_tap (handle_tap
, as you did) and call open_view()
in there.
Ah alright, I see. That's the right way to do it. So the only thing missing indeed is up-to-date documentation, no issues in code. Thanks again.
Duplicate Check
Describe the bug
With the update from Flet 0.22.1 to 0.23.X the SearchBar stopped working. The dropdown/list with results just doesn't open anymore. No error shown.
I've put a part of the code I'm using below but it also stopped working for me if I just follow the example from the docs.
Code
To reproduce
Expected behavior
No response
Screenshots
No response
Operating System
Linux
Operating system details
Debian sid
Flet version
0.23.2
Regression
Yes, it used to work in a previous Flet version (please specify the version in additional details)
Suggestions
No response
Additional details
Worked in Flet 0.22.1