Skip to content

Fix dropdown module accessing #34026

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

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions web_src/js/modules/fomantic/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down