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

[5.x]: New entry flyouts trap focus inside the sidebar #15314

Closed
MoritzLost opened this issue Jul 8, 2024 · 15 comments
Closed

[5.x]: New entry flyouts trap focus inside the sidebar #15314

MoritzLost opened this issue Jul 8, 2024 · 15 comments
Labels

Comments

@MoritzLost
Copy link
Contributor

What happened?

Description

When creating an entry from an entry model, the flyout sets the focus on the slug field, and it's impossible to focus the main field layout. See the following video:

entry-creation.mov

Steps to reproduce

  1. On an entries field, open the entry selection modal and then click on a new entry from there.

Expected behavior

  1. I would expect the initial focus to be on the title field, not the slug. Most of the time, I want to quickly enter a title and then hit CMD + S to exit out of the modal window.
  2. For accessibility, it's also problematic that there's no way to reach the main field layout. Focus should start on the title tabbing should take me to all the main entry fields, then continue in the sidebar.

Actual behavior

Focus starts out on the slug and there's no way to reach the title field through keyboard navigation.

Craft CMS version

5.2.5

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@MoritzLost MoritzLost added the bug label Jul 8, 2024
@brandonkelly
Copy link
Member

brandonkelly commented Jul 8, 2024

I’m not able to reproduce the initial focus bug. What browser are you using?

@MoritzLost
Copy link
Contributor Author

@brandonkelly Firefox, but I'm also seeing the error in Chrome and Safari. I checked again – looks like the focus starts out on the title (I can see the focus outline for a brief moment when the flyout opens), but then immediately switches to the slug. On inspection, the input for the title field has the autofocus attribute while the slug does not, so looks like JavaScript is switching the focus?

It's still happening in safe mode, so likely not related to a plugin or config.

@brandonkelly
Copy link
Member

Is this the native Title field, or a custom field?

@MoritzLost
Copy link
Contributor Author

@brandonkelly The native title field!

brandonkelly added a commit that referenced this issue Jul 9, 2024
@brandonkelly
Copy link
Member

Fixed the focus trap bug for the next Craft 4 and 5 releases. Still not able to reproduce the focus jumping bug though.

It could maybe stem from changes in #15252, but I don’t see how. Can you try rolling back to Craft 5.2.3 and see the bug still exists there?

@MoritzLost
Copy link
Contributor Author

@brandonkelly Still happening in 5.2.3 🤔 Cleared cache and cpresources, the focus still jumps from the title to the slug. Also tried with several different entry types (one with only the title field, one with title and one dropdown field, and one with a bunch of fields) – I'm seeing the same issue with all entry types.

Anything else I can try to narrow it down?

@brandonkelly
Copy link
Member

Craft 4.10.5 and 5.2.6 are out now with the focus trap fix.

No one on the team has been able to reproduce the focus jumping bug, though. Any chance you can send Composer files and a database backup into support@craftcms.com?

@MoritzLost
Copy link
Contributor Author

@brandonkelly Done! Hope this helps, let me know if you need any more information.

Curious that nobody can reproduce this, this is happening in both of my current Craft 5 projects. Though they're both based on the same boilerplate, so the same config. Maybe something in our config is somehow broken from a previous version?

@brandonkelly
Copy link
Member

Thanks for sending that in! We were able to reproduce with your files. Turns out the bug was triggered by the tooltip shown on the Author field, for users with long usernames/emails.

Fixed for the next release!

@MoritzLost
Copy link
Contributor Author

@brandonkelly Crazy 🤯

I just tested again (still on the previous version); I added a short username that doesn't overflow in the sidebar on my account. Still, the focus jumps from the title field to the Show Sidebar button on the top right. Is this the intended behaviour? Shouldn't the focus stay on the title field?

@brandonkelly
Copy link
Member

@MoritzLost Can you test the 5.x branch?

"craftcms/cms": "5.x-dev as 5.2.6",

@MoritzLost
Copy link
Contributor Author

@brandonkelly Still seeing this issue on the latest 5.x branch, unfortunately:

Screen.Recording.2024-07-16.at.17.34.37.mov

The focus starts out on the title but immediately jumps to the button on the top right.

The only changes I made since sending in the database dump:

  • Added a username (Moritz), previously it was empty, so it showed my email.
  • Updated to 5.x-dev

brandonkelly added a commit that referenced this issue Jul 16, 2024
@brandonkelly
Copy link
Member

Thanks! I was able to reproduce when creating a new entry via an entry selection modal like that. (I ended up being able to reproduce the previous bug when editing existing entry slideouts, so didn’t think to double-check that the fix worked when creating new entries.) Fixed now.

@brandonkelly
Copy link
Member

Craft 4.10.6 and 5.2.7 are out now with that fix. Thanks for bearing with me!

@MoritzLost
Copy link
Contributor Author

@brandonkelly Awesome, thanks! Just updated to 5.2.7, it's working perfectly now 👍

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

No branches or pull requests

2 participants