Browse Source

Fixes #5393 - Groups selection: Display bug when selecting subgroups.

Co-authored-by: Dusan Vuckovic <dv@zammad.com>
Co-authored-by: Mantas Masalskis <mm@zammad.com>
Dusan Vuckovic 4 months ago
parent
commit
43c7d1f636
1 changed files with 8 additions and 8 deletions
  1. 8 8
      app/assets/javascripts/app/lib/app_post/searchable_select.coffee

+ 8 - 8
app/assets/javascripts/app/lib/app_post/searchable_select.coffee

@@ -8,7 +8,6 @@ class App.SearchableSelect extends Spine.Controller
     'focus .js-shadow':                               'onShadowFocus'
     'change .js-shadow':                              'onShadowChange'
     'click .js-option':                               'selectItem'
-    'click .js-option .searchableSelect-option-text': 'selectItem'
     'click .js-enter .searchableSelect-option-text':  'selectItem'
     'click .searchableSelect-option-arrow':           'navigateIn'
     'click .js-back':                                 'navigateOut'
@@ -385,21 +384,22 @@ class App.SearchableSelect extends Spine.Controller
     @attribute.value = value
 
   selectItem: (event) ->
-    if $(event.target).hasClass('is-inactive')
+    row = $(event.currentTarget).closest('li')
+
+    if row.is('.has-inactive')
       event.stopPropagation()
       return
 
-    currentText = $(event.target).text().trim()
-    return if !currentText
+    currentText = row.find('[role=option]')[0]?.firstChild?.textContent?.trim()
+    return if not currentText
+
+    dataId = row.data('value')
 
-    dataId = $(event.target).closest('li').data('value')
-    currentText = $(event.target).text().trim()
-    displayName = $(event.target).closest('li').data('displayName')
     if @attribute.multiple
       event.stopPropagation()
       @addValueToShadowInput(currentText, dataId)
     else
-      @selectValue(dataId, currentText, displayName)
+      @selectValue(dataId, currentText, row.data('displayName'))
       @toggleClear()
 
     @markSelected(dataId)