mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 19:06:18 +01:00 
			
		
		
		
	Fix aria.js bugs: incorrect role element problem, mobile focus problem, tippy problem (#23450)
This PR is extracted from #23346 to address some unclear (I don't
understand) code-belonging concerns.
This PR needs to be backported, otherwise the `aria.js` is too buggy in
some cases. Since there would be two minor conflicts, I will do the
backport manually.
Before: the `aria.js` is still buggy in some cases.
After: tested with AppleVoice, Android TalkBack
* Fix incorrect dropdown init code
* Fix incorrect role element (the menu role should be on the `$menu`
element, but not on the `$focusable`)
* Fix the focus-show-click-hide problem on mobile. Now the language menu
works as expected
* Fix incorrect dropdown template function setting
* Clarify the logic in aria.js
* Hide item's tippy after menu gets hidden
* Fix incorrect tippy `setProps` after `destroy`
* Fix UI lag problem when page gets redirected during menu hiding
animation with screen reader
* Improve comments
* Implement the layout proposed by #19861
<details>
d74a7efb60/web_src/js/features/aria.md (L38-L47)
</details>
			
			
This commit is contained in:
		| @@ -89,9 +89,14 @@ export function initGlobalCommon() { | ||||
|  | ||||
|   // Semantic UI modules. | ||||
|   const $uiDropdowns = $('.ui.dropdown'); | ||||
|   $uiDropdowns.filter(':not(.custom)').dropdown({ | ||||
|     fullTextSearch: 'exact' | ||||
|   }); | ||||
|  | ||||
|   // do not init "custom" dropdowns, "custom" dropdowns are managed by their own code. | ||||
|   $uiDropdowns.filter(':not(.custom)').dropdown({fullTextSearch: 'exact'}); | ||||
|  | ||||
|   // The "jump" means this dropdown is mainly used for "menu" purpose, | ||||
|   // clicking an item will jump to somewhere else or trigger an action/function. | ||||
|   // When a dropdown is used for non-refresh actions with tippy, | ||||
|   // it must have this "jump" class to hide the tippy when dropdown is closed. | ||||
|   $uiDropdowns.filter('.jump').dropdown({ | ||||
|     action: 'hide', | ||||
|     onShow() { | ||||
| @@ -101,17 +106,23 @@ export function initGlobalCommon() { | ||||
|     }, | ||||
|     onHide() { | ||||
|       this._tippy?.enable(); | ||||
|  | ||||
|       // hide all tippy elements of items after a while. eg: use Enter to click "Copy Link" in the Issue Context Menu | ||||
|       setTimeout(() => { | ||||
|         const $dropdown = $(this); | ||||
|         if ($dropdown.dropdown('is hidden')) { | ||||
|           $(this).find('.menu > .item').each((_, item) => { | ||||
|             item._tippy?.hide(); | ||||
|           }); | ||||
|         } | ||||
|       }, 2000); | ||||
|     }, | ||||
|     fullTextSearch: 'exact' | ||||
|   }); | ||||
|   $uiDropdowns.filter('.slide.up').dropdown({ | ||||
|     transition: 'slide up', | ||||
|     fullTextSearch: 'exact' | ||||
|   }); | ||||
|   $uiDropdowns.filter('.upward').dropdown({ | ||||
|     direction: 'upward', | ||||
|     fullTextSearch: 'exact' | ||||
|   }); | ||||
|  | ||||
|   // special animations/popup-directions | ||||
|   $uiDropdowns.filter('.slide.up').dropdown({transition: 'slide up'}); | ||||
|   $uiDropdowns.filter('.upward').dropdown({direction: 'upward'}); | ||||
|  | ||||
|   attachDropdownAria($uiDropdowns); | ||||
|  | ||||
|   attachCheckboxAria($('.ui.checkbox')); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user