angular-selectize.js icon indicating copy to clipboard operation
angular-selectize.js copied to clipboard

onOptionSelect: dropdown options menu disappears and shows up again

Open chrisv-dev opened this issue 9 years ago • 1 comments

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

chrisv-dev avatar Feb 10 '16 15:02 chrisv-dev

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;
    }

impworks avatar Apr 26 '16 12:04 impworks