Autofocus not working
I have used the ->autofocus() in the main field of the form, but when I click on CREATE button, the form appears but the field is not focused at all. Is is happening to me in all resources.
Any idea, please?
19 Replies
I think someone else had this issue. Not sure if it's related to Filament or Livewire. Best to open an issue on GitHub.
php artisan about
what is the Filament version?It is version 3.0.0
run composer update
it is working here
done!!! But still NOT working.
In any Resource.
😩
console errors?
Can you create a repo on github?
I have a repo:
https://github.com/albertlens/rds_notarios/tree/seguimiento
Any help will be highly appreciated.
Thank you.
GitHub
GitHub - albertlens/rds_notarios at seguimiento
Contribute to albertlens/rds_notarios development by creating an account on GitHub.
@albertlens did you find a solution? I Have the same problem
I think this is a problem when multiple livewire requests are made. Seems to me that autofocus works fine with one request, but additional requests, like for things with entangled state like selects or fileuploads cause additional requests.
I have a pretty simple form:
When you load the page how many livewire requests do you see in the network tab of dev tools?
Autofocus has always seemed buggy to me in LW though.
Only 1
http://localhost/livewire/update
Interesting.
I’ve had to go as far as implementing a js solution in some of my apps. Still haven’t found a good solid reason for it not working sometimes. Even trap seems to loose focus on modals sometimes.
This is a request for a global search. If I deactivate it, there are no requests
Yea. Not 100% sure. I’ve seen issues with it even in LW2 in non filament apps, so I’m sure it’s not a filament thing.
Just haven’t been able to track down what’s causing it to lose focus after the page load.
Ok. I'll try to recreate it in a clean project and report the bug
It works in a fresh repository. So there is a problem in our code
I reproduced the bug. https://github.com/filamentphp/filament/issues/8296
This happens because
->sidebarCollapsibleOnDesktop()
in AdminPanelProviderGitHub
Autofocus not working with ->sidebarCollapsibleOnDesktop() · Issue ...
Package filament/filament Package Version v3.0.39 Laravel Version v10.22.0 Livewire Version v3.0.1 PHP Version 8.1 Problem description ->autofocus() doesn't make any effect when ->sidebar...
I have observed a strange behaviour.
Locally it is not working, but when I take the code to production, I mean, I publish it on GitHub and update my end-user website which I control with forge.laravel it does work.
Locally it does not work.
Up in the server it DOES work.
No changes at all in code.
Strange, isn't it?
And, besides, up in the server, when accessing via mobile phone, it does NOT work, either.
When I put autofocus in code, it worked on the first page refresh, but not after that.