Skip to content

Commit efd5176

Browse files
authored
Fix Fomantic UI dropdown icon bug when there is a search input in menu (#27225)
Fix #27224 And add the case to the devtest page.
1 parent da0467e commit efd5176

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

templates/devtest/gitea-ui.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<span class="text">simple</span>
172172
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
173173
<div class="menu">
174+
<div class="ui icon search input"><i class="icon">{{svg "octicon-search"}}</i><input type="text" value="search input in menu"></div>
174175
<div class="item">item</div>
175176
</div>
176177
</div>

web_src/js/modules/fomantic.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export function initGiteaFomantic() {
1616
$.fn.dropdown.settings.fullTextSearch = 'exact';
1717
// Do not use "cursor: pointer" for dropdown labels
1818
$.fn.dropdown.settings.className.label += ' gt-cursor-default';
19+
// The default selector has a bug: if there is a "search input" in the "menu", Fomantic will only "focus the input" but not "toggle the menu" when the "dropdown icon" is clicked.
20+
// Actually, the "search input in menu" shouldn't be considered as the dropdown's input
21+
$.fn.dropdown.settings.selector.search = '> input.search, :not(.menu) > .search > input, :not(.menu) input.search';
1922
// Always use Gitea's SVG icons
2023
$.fn.dropdown.settings.templates.label = function(_value, text, preserveHTML, className) {
2124
const escape = $.fn.dropdown.settings.templates.escape;

0 commit comments

Comments
 (0)