Skip to content

Commit c7b85f7

Browse files
authored
Fix dropdown module accessing (#34026)
Follow #34014.
1 parent d70be9d commit c7b85f7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

web_src/js/modules/fomantic/dropdown.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ export function initAriaDropdownPatch() {
2121
function ariaDropdownFn(this: any, ...args: Parameters<FomanticInitFunction>) {
2222
const ret = fomanticDropdownFn.apply(this, args);
2323

24-
for (const el of this) {
24+
for (let el of this) {
25+
// dropdown will replace '<select class="ui dropdown"/>' to '<div class="ui dropdown"><select (hidden)></select><div class="menu">...</div></div>'
26+
// so we need to correctly find the closest '.ui.dropdown' element, it is the real fomantic dropdown module.
27+
el = el.closest('.ui.dropdown');
2528
if (!el[ariaPatchKey]) {
2629
// the elements don't belong to the dropdown "module" and won't be reset
2730
// so we only need to initialize them once.
2831
attachInitElements(el);
2932
}
3033

31-
// if the `$().dropdown()` call is without arguments, or it has non-string (object) argument,
34+
// if the `$().dropdown()` is called without arguments, or it has non-string (object) argument,
3235
// it means that such call will reset the dropdown "module" including internal settings,
3336
// then we need to re-delegate the callbacks.
3437
const $dropdown = $(el);

0 commit comments

Comments
 (0)