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

[Proposal] Improve the dropdown step by step #23345

Closed
wxiaoguang opened this issue Mar 7, 2023 · 3 comments
Closed

[Proposal] Improve the dropdown step by step #23345

wxiaoguang opened this issue Mar 7, 2023 · 3 comments
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Mar 7, 2023

The Problem

Gitea uses Fomantic UI Dropdown heavily, but the dropdown has many unfixable problems and already causes a lot of bugs for a11y.

The root problem is that Fomantic Dropdown was designed to be used for many different purposes (as much as possible ...)

  • Menu (the profile menu in navbar, the language menu in footer)
  • Popup (the branch/tag panel, the review box)
  • Simple <select> , used in many forms
  • Searchable option-list with static items (used in many forms)
  • Searchable option-list with dynamic items (ajax)
  • Searchable multiple selection option-list with dynamic items: the repo topic setting
  • More complex usages, like the Issue Label selector

And Fomantic Dropdown requires that the focus must be on its primary element, see aria.md. If the focus changes, it hides or panics. If we treat the dropdown as a single element, the focusing behavior is fine, but if the dropdown is used for complex interaction, it would cause problems.

Before: aria.js could fix many a11y related problems and it even works with screen readers. However, the ending time of that hacky patch comes sooner or later.

Some following fixes:

The Future

  • Use native <select> as much as possible
  • Re-use the Fomantic Dropdown styles but rewrite the code for different purposes one by one.
  • Choose other components to replace Fomantic Dropdown.
  • (TODO)
@wxiaoguang wxiaoguang added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Mar 7, 2023
@silverwind
Copy link
Member

silverwind commented Mar 8, 2023

Native select is probably a good first step, but I recommend putting it into a separate go subtemplate so it can easily be replaced/extended later where only 1 file needs to be edited instead of 50+.

Ideally that subtemplate would take a dict of options instead of a inflexible argument list.

lafriks pushed a commit that referenced this issue Mar 11, 2023
Follow: 
* #23345

The branch/tag selector dropdown mixes jQuery/Fomantic UI/Vue together,
it's very diffcult to maintain and causes unfixable a11y problems. It
also causes problems like #19851 #21314 #21952

This PR is the first step for the refactoring, move `data-` attributes
to JS object and use Vue data as much as possible.

The old selector `'.choose.reference .dropdown'` was also wrong, it hits
`<div class="choose reference"><svg class="dropdown icon">` and would
cause undefined behaviors.

I have done some quick tests and it works. After this PR gets merged, I
will move the code into a Vue SFC in next PR.



![image](https://user-images.githubusercontent.com/2114189/224099638-378a8a86-0865-47d1-bcba-f972506374c7.png)


![image](https://user-images.githubusercontent.com/2114189/224099690-70276cf5-b1e4-404a-b0c6-582448abf40e.png)

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@silverwind
Copy link
Member

silverwind commented Mar 30, 2023

There's also a web standard proposal for <selectmenu>, which looks like a styleable version of <select>, so if we can get all native selects into a subtemplate, it'll be easy to switch later. There is a polyfill but I can't speak for its quality.

@wxiaoguang
Copy link
Contributor Author

The plan is utopia but I don't want to spend time on it at the moment.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants