In lang_dropdown.js in the DDSlick implementation (~line 43) it sets a data value to 0 when setting up the dropdown, In DDSelect's onSelected handler it checks this value and only redirects if the value is not empty, it then sets the value to 1.

          else if (msddSettings.widget == "ddslick") {
            $.data(document.body, 'ddslick'+key+'flag', 0);
            select.ddslick({
              width: msddSettings.width,
              height: (msddSettings.height == 0) ? null : msddSettings.height,
              showSelectedHTML: Boolean(msddSettings.showSelectedHTML),
              imagePosition: msddSettings.imagePosition,
              onSelected: function(data) {
                var i = $.data(document.body, 'ddslick'+key+'flag');
                if (i) {
                  $.data(document.body, 'ddslick'+key+'flag', 0);
                  var lang = data.selectedData.value;
                  var href = $('#lang-dropdown-select-'+key).parents('form').find('input[name="' + lang + '"]').val();
                  window.location.href = href;
                }
                $.data(document.body, 'ddslick'+key+'flag', 1);
              }
            });
          }

Presumably this is because the onSelected method gets triggered once in the setup process and we don't want that to cause a redirect.

However if the behavior ever gets run again then the line where the value gets set to 0 runs again, but this doesn't trigger an additional call to the onSelected callback. Therefore the next time someone tries to change change the select value the value is empty and there's no redirect.

I thought of just adding a condition around $.data(document.body, 'ddslick'+key+'flag', 0); so that it only sets the value to 0 if there isn't already a value, but ultimately it should probably be forcing the setup of the dropdowns to only happen once so wrapping most of the code in a .once() seems sensible.

patch to follow

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PQ’s picture

Patch attached

PQ’s picture

I've attached a copy of the patch created with -w (ignore whitespace) so it's a lot easier to see what's actually changed.

Rajab Natshah’s picture

Assigned: Unassigned » Rajab Natshah
Status: Active » Needs review
kala4ek’s picture

Assigned: Rajab Natshah » kala4ek
kala4ek’s picture

Assigned: kala4ek » Unassigned
Status: Needs review » Fixed
PQ’s picture

Excellent to hear that this is in. Is there any chance of a retrospective credit on the other issue? I don't know if that's something that's possible to do.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.