mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	Fix navbar + menu flashing on page load (#31281)
				
					
				
			Fixes https://github.com/go-gitea/gitea/pull/31273#issuecomment-2153771331. Same method as used in https://github.com/go-gitea/gitea/pull/30215. All left-opening dropdowns need to use it method. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		| @@ -94,6 +94,22 @@ function delegateOne($dropdown) { | ||||
|     updateSelectionLabel($label[0]); | ||||
|     return $label; | ||||
|   }); | ||||
|  | ||||
|   const oldSet = dropdownCall('internal', 'set'); | ||||
|   const oldSetDirection = oldSet.direction; | ||||
|   oldSet.direction = function($menu) { | ||||
|     oldSetDirection.call(this, $menu); | ||||
|     const classNames = dropdownCall('setting', 'className'); | ||||
|     $menu = $menu || $dropdown.find('> .menu'); | ||||
|     const elMenu = $menu[0]; | ||||
|     // detect whether the menu is outside the viewport, and adjust the position | ||||
|     // there is a bug in fomantic's builtin `direction` function, in some cases (when the menu width is only a little larger) it wrongly opens the menu at right and triggers the scrollbar. | ||||
|     elMenu.classList.add(classNames.loading); | ||||
|     if (elMenu.getBoundingClientRect().right > document.documentElement.clientWidth) { | ||||
|       elMenu.classList.add(classNames.leftward); | ||||
|     } | ||||
|     elMenu.classList.remove(classNames.loading); | ||||
|   }; | ||||
| } | ||||
|  | ||||
| // for static dropdown elements (generated by server-side template), prepare them with necessary aria attributes | ||||
|   | ||||
		Reference in New Issue
	
	Block a user