farend / redmine_searchable_selectbox

This plugin changes Redmine's selectbox searchable.
GNU General Public License v2.0
27 stars 10 forks source link

Behavior when selecting pull-down items #23

Open D-fujinami opened 1 year ago

D-fujinami commented 1 year ago

When I create a new ticket in redmine, when I click on a pull-down item the screen scrolls to the bottom and I have to go back to the pull-down. Is there any way to fix this?

A similar event seems to be occurring with select2 4.0.12, which is used inside Redmine. It seems like it could be handled by updating the version of select2 used in the plugin, though, Does redmine_searchable_selectbox support select2 4.0.13? https://github.com/select2/select2/pull/5734

Environment:
  Redmine version                5.0.2.stable
  Ruby version                   3.0.4-p208 (2022-04-12) [x86_64-linux]
  Rails version                  6.1.6
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Farend_bleuclair (includes JavaScript)
SCM:
  Subversion                     1.14.2
  Git                            2.36.1
  Filesystem                     
Redmine plugins:
  additional_tags                1.0.7
  additionals                    3.0.8
  ankoalm_ganttchart             3.2.19
  openalm_common                 1.7.7
  redmine_searchable_selectbox   0.1.10
  redmine_slack                  0.2

*This post uses Google Translate.

ishikawa999 commented 1 year ago

@D-fujinami

Thank you for the feedback. I couldn't reproduce the issue in my environment, but I've updated select2 to version 4.0.13 as a precaution. Could you please check if the issue is resolved?

https://github.com/farend/redmine_searchable_selectbox/releases/tag/v0.1.11

nightmeteora commented 11 months ago

@D-fujinami

Thank you for the feedback. I couldn't reproduce the issue in my environment, but I've updated select2 to version 4.0.13 as a precaution. Could you please check if the issue is resolved?

https://github.com/farend/redmine_searchable_selectbox/releases/tag/v0.1.11

It does not work even I updated select2 to 4.1.0_rc. Finally I happened to find the root cause of a repro via chrome dev tools.

when additional_tags plugin was installed at same time, its loads select2 and transforms textarea with class .select2-search__field, which is target element to focus on by seachable_selectbox

// Fix a problem with focus not working in Redmine 5.0 or later.
// issue: https://github.com/select2/select2/issues/5993
$(document).on('select2:open', function() {
  document.querySelector('.select2-search__field').focus();
});

the additional_tags textarea locates at the almost bottom of the new issue page, the focus() triggers the scrolling-down.

I did a quick fix and it works well for me. I am not familiar with JS, please correct me if it has potential issue.

//workaround
- document.querySelector('.select2-search__field').focus();
+ document.querySelector('input.select2-search__field:not([placeholder="Add tags"])').focus();
ishikawa999 commented 11 months ago

@nightmeteora Ah, I see, it was influenced by other plugins. If the code you suggested resolves the issue, it seems like a good solution as it would not harm users who are not using the plugins. Please give me some time to gather the plugins and verify this when I have a moment. thank you for your feedback.

hxqqqqqq commented 2 months ago

I found that using the default theme does not have this issue, but using "Purplemine2-2.16.2" only has this problem. So what is the specific reason for this, huh? Do any experts have a solution?