Skip to content

Fix autofocus behavior #34397

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented May 8, 2025

The "autofocus" was abused or misbehaved:

  1. When users visit a page but they are not going to change a field, then the field shouldn't get "autofocus"
    • the "auth" / "user" page: in most cases, users do not want to change the names
    • see also the GitHub's "settings" page behavior.
  2. There shouldn't be duplicate "autofocus" inputs in most cases, only the first one focuses
  3. When a panel is shown, the "autofocus" should get focus
    • "add ssh key" panel

This PR fixes all these problems and by the way remove duplicate "isElemHidden" function.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 8, 2025
@github-actions github-actions bot added modifies/templates This PR modifies the template files modifies/frontend labels May 8, 2025
@wxiaoguang
Copy link
Contributor Author

image

@wxiaoguang wxiaoguang added this to the 1.25.0 milestone May 8, 2025
@silverwind
Copy link
Member

silverwind commented May 8, 2025

I agree we should eliminate most if not all autofocus, it's often distruptive to UX flow. The one on the frontpage is something many users may be used to, so probably keep that.

The only valid use case for autofocus that I see is when opening a modal to autofocus the first input within the modal, but I assume this is best done with some JS instead of the autofocus attribute.

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented May 8, 2025

The only valid use case for autofocus that I see is when opening a modal to autofocus the first input within the modal, but I assume this is best done with some JS instead of the autofocus attribute.

Fomantic UI already does so:

image

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/frontend modifies/templates This PR modifies the template files type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants