Fix form field focusing on modal actions in relation managers #15430
+0
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Opening a modal from a relation manager causes focus issues with form fields. Some of the symptoms of this bug are:
I’ve tracked this down to the
tabindex="0"
on the relation manager when multiple relation managers are used. The tabindex seems to be conflicting with the modal's focusing.This is probably some type of conflict/bug with livewire or alpine.js's focus trap, as
tabindex="0"
has been in core for more than 2 years. But ultimately, I'm unsure as to whytabindex="0"
is used at all. You can already tab to the RM's buttons/links without it. And Filament doesn't add tabindex to subnavigation groups for example. (That said I'm not an accesibility expert either).This is only an issue when multiple relation managers (or relation manager groups) are on the page (ie when the tab navigation component is displayed). Displaying a single relation manager or single relation manager group doesn't cause this issue as
tabindex="0"
is only added conditionaly when more than one RM are displayed via tabs.I did try rolling back filament and livewire as far as I could go and still ran into this issue so not sure what version of filament/livewire/alpine this was introduced in
Visual changes
Here's a video of the issue from Filament's demo page, but this issue has also been confirmed in our production app, as well as my plugin demo app.
tabindex.mov
Functional changes
This PR just removes
tabindex="0"
from the conditional.I've also tested that:
->modalAutoFocus(false)
also continues to workIf there is a better way to handle this then let me know.
composer cs
command.After doing some more investigating this should also address and close #15289, #14999, #14913
There could be other issues out there, but that's as far as I looked.