Skip to content
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

Fix form field focusing on modal actions in relation managers #15430

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

archilex
Copy link
Contributor

Description

Opening a modal from a relation manager causes focus issues with form fields. Some of the symptoms of this bug are:

  1. When any RM modal is opened (header action, table action, filters in a slideover, etc.), text fields remains selected even after clicking out of the field.
  2. Typing after clicking out of the field continues to update the field.
  3. Since the text field remains selected, trying to trigger buttons, toggles, doesn’t work.
  4. If your form is long and scrolls, clicking a button at the bottom will scroll you back to the still selected field.
  5. To trigger a button/toggle/radio deck etc. you have to double click quickly, which apparentetly breaks through the focus issue (however only for that click).

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 why tabindex="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:

  1. The relation manager's actions, links, etc. can still be tabbed to,
  2. When opening a modal, the autofocus is still applied to the first element,
  3. Focus trapping still works.
  4. ->modalAutoFocus(false) also continues to work

If there is a better way to handle this then let me know.

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

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.

@bzy107
Copy link
Contributor

bzy107 commented Jan 24, 2025

The issue with #13661 has also been resolved. Congratulations!

@arshaviras
Copy link
Contributor

arshaviras commented Jan 26, 2025

The issue #14999 also resolved, thanks!

@gustavocaiano
Copy link

Can confirm the issue #15289 is resolved with this. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

clicking in a modal with focused element out of the screen makes the modal jump to said element
4 participants