EvanOxfeld / angular-selectize.js

Angular Selectize directive for a hybrid textbox + <select> box. Supports ngOptions and two-way bindings.
MIT License
34 stars 16 forks source link

onOptionSelect: dropdown options menu disappears and shows up again #37

Open chrisv-dev opened 8 years ago

chrisv-dev commented 8 years ago

When selecting an option (by clicking or using enter key) for the first time (!) after pageload, the list of all options disappears and shows up again. After selecting the desired option once again, the options disappear and from this moment everything is working fine.

This problem also occurs in the provided demo: http://plnkr.co/edit/4BuWxF

impworks commented 8 years ago

I came across this issue today in my project and found the reason behind it: when the watches initially fire on page load, both optionsUpdate and modelUpdate flags are set, while usually only one of them should be set at a given time. The scheduleUpdate function should reset both flags if Selectize has not yet been initialized:

function scheduleUpdate() {
    if (!selectize) {
        if (!initializing) {
            initSelectize();
        }

        // ===== Added =====
        modelUpdate = optionsUpdate = false;
        // ===== Added =====

        return;
    }