diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-04-30 10:00:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-30 02:00:36 +0000 |
commit | ba5c3f808768f46d20d723e7f062b4d970165067 (patch) | |
tree | f622a9496a86695aa8cad9ff653418788c61ae9e /web_src/js/modules | |
parent | ce6699db019c05eee5ec32c6dc5ffefa32b06ace (diff) | |
download | gitea-main.tar.gz gitea-main.zip |
Also fix #34300
Diffstat (limited to 'web_src/js/modules')
-rw-r--r-- | web_src/js/modules/fomantic/dropdown.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/web_src/js/modules/fomantic/dropdown.ts b/web_src/js/modules/fomantic/dropdown.ts index 1b05939cf3..0360b8ef95 100644 --- a/web_src/js/modules/fomantic/dropdown.ts +++ b/web_src/js/modules/fomantic/dropdown.ts @@ -228,12 +228,13 @@ function attachDomEvents(dropdown: HTMLElement, focusable: HTMLElement, menu: HT dropdown.addEventListener('keydown', (e: KeyboardEvent) => { // here it must use keydown event before dropdown's keyup handler, otherwise there is no Enter event in our keyup handler if (e.key === 'Enter') { - const dropdownCall = fomanticDropdownFn.bind($(dropdown)); - let $item = dropdownCall('get item', dropdownCall('get value')); - if (!$item) $item = $(menu).find('> .item.selected'); // when dropdown filters items by input, there is no "value", so query the "selected" item + const elItem = menu.querySelector<HTMLElement>(':scope > .item.selected, .menu > .item.selected'); // if the selected item is clickable, then trigger the click event. // we can not click any item without check, because Fomantic code might also handle the Enter event. that would result in double click. - if ($item?.[0]?.matches('a, .js-aria-clickable')) $item[0].click(); + if (elItem?.matches('a, .js-aria-clickable') && !elItem.matches('.tw-hidden, .filtered')) { + e.preventDefault(); + elItem.click(); + } } }); |