-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added autocomplete options to url input #128
Conversation
lib/screens/login_screen.dart
Outdated
@@ -266,3 +259,68 @@ class LoginScreen extends HookConsumerWidget { | |||
.trim(); | |||
} | |||
} | |||
|
|||
class UrlFieldInput extends ConsumerWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract the widget to another file.
Im abroad and can’t test this, but I’m curious if tab-to-complete works with this. Does anybody know? |
I tried unsuccessfully to add the shortcut; my best guess is that the textfield is capturing the tab event preventing the shortcut to execute. |
i am not sure how to disable that behaviour |
Can we extend TextField? |
Probably, but I don't think textfield itself is the issue its something related to focus and focus node |
tab.mp4The flickering is me pressing tab |
Just glancing but maybe DefaultTextEditingAction |
I tried it still the same behavior, the autocomplete is made up of 2 parts a textfield and a listview that displays the options, now I am not sure if focus is passed to the listview or remains with textfield. which I believe is the issue, If the focus remains with textfield (which I suspect it is) when we press tab the textfield attempts to go to the next field which resets autocomplete causing the behavior in the video. but I could be wrong and its not any of the above |
yeah i changed the shortcut to ctrl_space it still wont work I am pretty sure it's a focus issue |
hmm. this problem is actually super sticky because the intuitive behavior of the tab key is extremely complicated.
Note that this does not work because of the broken null check operators and whatnot but I think this should be enough to get past the blockage. |
I changed how options are autocompleted, inspired by @sevenrats' solution. The gist is that I used Riverpod statenotifiers to sync the state with autocomplete and the textbox. Let me know if there is some weird behavior. Please build it locally and test it out. |
the shortcut is firing for me but new servers don't get stored and the shortcut doesn't actually cause selection to happen, though clicking does. |
wdym its working for me Recording.2024-09-22.130452.mp4 |
Are you sure you pushed all changes? What is you dev platform? |
Windows, everything should be pushed; whats the issue you are running into, you have to use arrow keys to select the urls |
one, my list only ever contains "http" and "https" it doesnt contain any servers. so maybe thats the issue. |
ok i solved the first issue. "log out" destroys the session obviously so thats just me being dumb. enter still doesnt work though even after I add several profiles. plus, the http and https strings need to go unless we can make those work as expected. |
ah, and now I am getting your catch string. flutter: Option list accessed a element out of bounds |
no i made a mistake, i didnt take care of HTTP, https I match only with previous addresses, it will not fill if its http or https only fixing it |
i added some new debug prints what is the optionslist and selectedindex |
there is a reason for the empty options, though; I think there is some sort of race condition, or the state is not being updated, so the options provider is not filled even after the list is built. But I cant seem to recreate it, it does it randomly |
sorry this is probably my fault. i think i was overcasting the pull by having a local change in the tree. stand by. |
why is video state pulled in? |
wdym |
flutter: Option list accessed a element out of bounds something is definitely bugged out with the state. |
should be fixed |
got it ill switch to watch, the tabbing thing will not work with autocomplete; you have to press ESC first if the autocomplete options are being shown then you can tab out |
thanks sevenrats
ah. lets make the select function close the autocomplete then, and reopen it on subsequent keypresses, yeah? |
I made it so that options are automatically hidden if we have the exact value as the options, check it out, works pretty nice now |
yeah that works great. awesome! I will do a syntactical review after work. |
ok I hate to say it but I think this needs a little more time in the oven. I've done some experiments that make it clear that we can actually have everything we want (tab and enter to select with properly preserved focus hierarchy) we just need to restructure behind a FocusGroup of some kind. If you want to keep running this ball I can give you info on the experiements I've done or I will just try to work up a pr into your branch some time this week. |
What else needs to be added ? |
removed some redundant code, and added comments, shouldn't break anything |
Are the changes compatible with d-Pad navigation for AndroidTV? |
I have no way to test that, but I didn't change any default nav behaviour just how the options are filled (removed a unnecessary provider) |
If flutter supports dpad similar to arrow keys it should work |
The Android emulator can also emulate TVs. Yes, dpad navigation are just arrow keys. |
It'll work then, also the form is already wrapped in a focus group, because of password auto fill stuff. |
@jdk-21 I strongly recommend that we revert this. It's not feature complete and contains unnecessary technical debt. |
Implemented #127, had to make a custom autocomplete because the default one does not accept a controller and defaults to maxwidth.
If no addresses are found:
If previous address are present: