-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Replace autofocus
with data-global-init="initInputAutoFocusEnd"
.
#34252
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
base: main
Are you sure you want to change the base?
Conversation
For most pages, the "autofocus" or "initInputAutoFocusEnd" seems abused. I would suggest either leave autofocus as-is, or just remove it, but don't make it more complex than it should be. |
My viewpoints are as follows: As I'm writing this, I'm thinking about whether we can add a utility function in the Go code:
func inputAttrs(value string) string {
if value != "" {
return "data-global-init=\"initInputAutoFocusEnd\""
}
return "autofocus"
}
This is just a preliminary idea. My point is that we should either not implement autofocus at all or implement it properly. We can't do a half - baked job. |
Why they should be focused? Does end user would really like to input anything in most cases? Take GitHub as an example, most input doesn't get "autofocus" on most pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't make changes which you don't understand.
Yes, so my view is that if the |
159ebec
to
c0f8c62
Compare
@@ -12,7 +12,7 @@ | |||
<span class="text red tw-hidden" id="name-change-prompt"> {{ctx.Locale.Tr "settings.change_username_prompt"}}</span> | |||
<span class="text red tw-hidden" id="name-change-redirect-prompt"> {{ctx.Locale.Tr "settings.change_username_redirect_prompt"}}</span> | |||
</label> | |||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if or (not .SignedUser.IsLocal) ($.UserDisabledFeatures.Contains "change_username") .IsReverseProxy}}disabled{{end}} maxlength="40"> | |||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" data-global-init="initInputAutoFocusEnd" required {{if or (not .SignedUser.IsLocal) ($.UserDisabledFeatures.Contains "change_username") .IsReverseProxy}}disabled{{end}} maxlength="40"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you assume that when a user goes to the "settings profile" page, they are highly likely going to change their username?
If they don't want to change their username, why the input should be auto-focused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The starting point is as follows:
I was about to edit my username. When I came to this page, the input box for the username had already gained focus because the autofocus
attribute was added to the input
element.
Then:
① I had to click at the end of the input
box, press the Backspace
key to delete the original username, and then enter a new one.
② Or, I could press the Delete
key to delete the original username and then enter a new one.
At least in my opinion, ordinary people use the Backspace
key far more frequently than the Delete
key. So I thought it was unreasonable, and that's why I naturally submitted this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no interest to do more arguments.
In short: GitHub doesn't do so, Discord doesn't do so, I guess GitLab doesn't do so either.
I do not see any website do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It is NOT username
- It is NOT autofocus or initInputAutoFocusEnd. They WILL NOT WORK because the element is hidden when the page loads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The screenshot of GitHub is RIGHT because when a user clicks "Edit Profile", they ARE HIGHLY LIKELY going to edit their "display" name, and that focus helps to make the newly shown "edit profile form" focused. That's different from a NORMAL page.
But as I said above: Gitea's most "autofocus" usages are abuses.
Why you assume that when a user goes to the "settings profile" page, they are highly likely going to change their username?
I reverted all the other modifications and only kept the changes on the page shown in my screenshot. |
before:

after:
