]> source.dussan.org Git - gitea.git/commitdiff
Fix Fomantic UI dropdown icon bug when there is a search input in menu (#27225) ...
authorGiteabot <teabot@gitea.io>
Sun, 24 Sep 2023 13:42:00 +0000 (21:42 +0800)
committerGitHub <noreply@github.com>
Sun, 24 Sep 2023 13:42:00 +0000 (13:42 +0000)
Backport #27225 by @wxiaoguang

Fix #27224

And add the case to the devtest page.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
templates/devtest/gitea-ui.tmpl
web_src/js/modules/fomantic.js

index 258b72f8cd5f006fb004ca18bb7045cb5ee3c849..e15ed0b8df36aba5143634269168b366118ca385 100644 (file)
                                <span class="text">simple</span>
                                {{svg "octicon-triangle-down" 14 "dropdown icon"}}
                                <div class="menu">
+                                       <div class="ui icon search input"><i class="icon">{{svg "octicon-search"}}</i><input type="text" value="search input in menu"></div>
                                        <div class="item">item</div>
                                </div>
                        </div>
index ab5f842bc6ca49bd127fe242ac19d7ddf1ca7ebe..3d4a66c1ea9ddb35c50ef07071cee06982b1179a 100644 (file)
@@ -16,6 +16,9 @@ export function initGiteaFomantic() {
   $.fn.dropdown.settings.fullTextSearch = 'exact';
   // Do not use "cursor: pointer" for dropdown labels
   $.fn.dropdown.settings.className.label += ' gt-cursor-default';
+  // 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.
+  // Actually, the "search input in menu" shouldn't be considered as the dropdown's input
+  $.fn.dropdown.settings.selector.search = '> input.search, :not(.menu) > .search > input, :not(.menu) input.search';
   // Always use Gitea's SVG icons
   $.fn.dropdown.settings.templates.label = function(_value, text, preserveHTML, className) {
     const escape = $.fn.dropdown.settings.templates.escape;