diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-03-27 00:01:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-26 16:01:43 +0000 |
commit | c7b85f7070b4bebb34327e99a6940b68bf202163 (patch) | |
tree | a9bfeba48d7e5c50cff30523b35d4feec0bac483 /web_src | |
parent | d70be9d0fe648a7b593c4df46ac61e18d4166d07 (diff) | |
download | gitea-c7b85f7070b4bebb34327e99a6940b68bf202163.tar.gz gitea-c7b85f7070b4bebb34327e99a6940b68bf202163.zip |
Fix dropdown module accessing (#34026)
Follow #34014.
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/modules/fomantic/dropdown.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/web_src/js/modules/fomantic/dropdown.ts b/web_src/js/modules/fomantic/dropdown.ts index 4bd08c5226..1b05939cf3 100644 --- a/web_src/js/modules/fomantic/dropdown.ts +++ b/web_src/js/modules/fomantic/dropdown.ts @@ -21,14 +21,17 @@ export function initAriaDropdownPatch() { function ariaDropdownFn(this: any, ...args: Parameters<FomanticInitFunction>) { const ret = fomanticDropdownFn.apply(this, args); - for (const el of this) { + for (let el of this) { + // dropdown will replace '<select class="ui dropdown"/>' to '<div class="ui dropdown"><select (hidden)></select><div class="menu">...</div></div>' + // so we need to correctly find the closest '.ui.dropdown' element, it is the real fomantic dropdown module. + el = el.closest('.ui.dropdown'); if (!el[ariaPatchKey]) { // the elements don't belong to the dropdown "module" and won't be reset // so we only need to initialize them once. attachInitElements(el); } - // if the `$().dropdown()` call is without arguments, or it has non-string (object) argument, + // if the `$().dropdown()` is called without arguments, or it has non-string (object) argument, // it means that such call will reset the dropdown "module" including internal settings, // then we need to re-delegate the callbacks. const $dropdown = $(el); |