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

Topics Save Button uses href with javascript protocol #19912

Closed
Ryuno-Ki opened this issue Jun 7, 2022 · 2 comments · Fixed by #21813
Closed

Topics Save Button uses href with javascript protocol #19912

Ryuno-Ki opened this issue Jun 7, 2022 · 2 comments · Fixed by #21813
Labels

Comments

@Ryuno-Ki
Copy link
Contributor

Ryuno-Ki commented Jun 7, 2022

Description

I noticed this while working on #19900.

In general, href="javascript:;" is an anti-pattern (see http://www.jibbering.com/faq/#javascriptURI for the original intent).
As a rule of thumb, links go somewhere and buttons are used to resolve actions.

<a class="ui button primary" href="javascript:;" id="save_topic"
data-link="{{.RepoLink}}/topics">{{.i18n.Tr "repo.topic.done"}}</a>

is the only occurence I could find so far. Since it is controlled by JavaScript alone, a fix would require the <a> to become <button type="button"> (or perhaps a submit button if there would be a <form> and Go-side logic to update the saved topics).
Plus some style changes to make it look like before.

Gitea Version

1.17.0+dev-675-g81cf00686

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

try.gitea.io

Database

No response

@wxiaoguang
Copy link
Contributor

There could be a lot of bad smells in a large project which is many years old ..... so, large projects always need maintaining and refactoring.

And I think the AJAX was used there to avoid page reload/refresh, just like what GitHub does, it seems no benefit to replace it with a form.

@silverwind
Copy link
Member

Proper solution is probably <a role="button">.

lunny pushed a commit that referenced this issue Nov 15, 2022
To use an anchor tag as a button and have it be accessible I added
`role="button" tabindex="0"`,
[reference](https://stackoverflow.com/a/10510353/7414734).

* Closes #19912
fsologureng pushed a commit to fsologureng/gitea that referenced this issue Nov 22, 2022
…#21813)

To use an anchor tag as a button and have it be accessible I added
`role="button" tabindex="0"`,
[reference](https://stackoverflow.com/a/10510353/7414734).

* Closes go-gitea#19912
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants