jquery-simple-combobox icon indicating copy to clipboard operation
jquery-simple-combobox copied to clipboard

The change event does not fire the first time a selection is made after a user enters text in the combo box

Open ben-m-lucas opened this issue 9 years ago • 3 comments

Steps to reproduce

  1. Enter text into the combo box
  2. Make a selection
  3. Note that the change event does not fire here
  4. Make another selection
  5. Now the change event fires

ben-m-lucas avatar Oct 21 '15 22:10 ben-m-lucas

I have found that I can correct the issue by commenting out lines 723-726 as shown in the following code snippet. I'm not sure what the purpose of these lines of code is for though so I'd like to know more about the implications:

    this.on('change', 'select', function (e, checkboxesMode) { // someone triggered combobox select change
        var $combo = $(this).closest(cp);
        var dtext = $('option:selected', this).text();
        $combo.children(cp + cdisplay).val(dtext).data('value', dtext);
        var $valueInput = $combo.children(cp + cvalue);
        //This bit of code is causing the change event to not fire if a user first types in a value and then selects an item in the list.
        //  if ($valueInput.data('changed')) {
        //      $valueInput.data('changed', false);
        //      return;
        //  }
        if (checkboxesMode) { // no slideup for checkboxes mode
            updateValueInput.call($combo);
            $valueInput.change();
            return;
        }
        $valueInput.change();
        slide.call($combo.children(cp + clist), 'up'); // can be triggered at the page load
    });

ben-m-lucas avatar Oct 21 '15 22:10 ben-m-lucas

@ben-m-lucas - I have created this fiddle that I think demonstrates what you mean:

http://jsfiddle.net/gjsjohnmurray/vgqvww6s/

I think the lines you commented out above are needed to suppress undesirable change events, for example if value is changed programmatically.

I will investigate the issue and try to provide a fix for the missing event.

gjsjohnmurray avatar Dec 09 '15 02:12 gjsjohnmurray

@gjsjohnmurray - Yes, that fiddle does demonstrate the issue. Thank you, and let me know what you find.

ben-m-lucas avatar Dec 09 '15 15:12 ben-m-lucas