Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sm-dropdown on-change function called on scroll #34

Open
ghost opened this issue Dec 18, 2017 · 4 comments
Open

sm-dropdown on-change function called on scroll #34

ghost opened this issue Dec 18, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 18, 2017

Hello guys,

First, congratulations on the work you have provided and many thanks for the useful functionality you provide. There is some weird behavior with the on-change function callback.

I have the following usage of the sm-dropdown component:

<sm-dropdown
    autocentrum-select
    ng-if="searchElement.nivel === 0"
    ng-class="{
         'ng-highlighted':
         cautareService.model[category.id][searchElement.id] &&
         cautareService.model[category.id][searchElement.id].length
     }"
    class="fluid multiple search selection"
    model="cautareService.model[category.id][searchElement.id]"
    items="searchElement.valori"
    label="item.valoare"
    value="item"
    on-change="updateChildSearchElementValues(searchElement)"
    default-text="searchElement.nume"
    name="autocomplete-select-{{searchElement.id}}"
    settings="{useLabels: false, message: {count: searchElement.nume + ' - {count} selectate' }}">
</sm-dropdown>```

The on-change callback function is called multiple times when you change the select value (5-6 times) and also, the biggest issue is that it gets called on every scroll event.

@ghost
Copy link
Author

ghost commented Dec 20, 2017

From what I noticed the on-change is called incorrectly. So there it should be: on-change="updateChildSearchElementValues". I am now correctly setting up the on-change event but this is called multiple times. The following scenario happens:

  1. You select a value, it is triggered 2 times;
  2. Select 2nd option: triggered 4 times
  3. Select 3rd option: triggered 6 times

Basically with a new selection added, the callback returns n*2 (n is the number of selected items).

@ghost
Copy link
Author

ghost commented Dec 20, 2017

Is this repository followed anymore?

@ClickerMonkey
Copy link
Owner

Greetings Florinmtsc!

The on-change attribute is tied directly into the Semantic UI library and is not evaluated by this library. You should check your Semantic UI version and if you are up to date perhaps try to report the issue in the main SUI repository.

There are plans to eventually change to using the ngModel directive which would allow you to use the ngChange event. But I don't know when I'll get to that.

There are a few other odd issues with smDropdown depending on how you are using it (I've experienced them myself but no one has reported them yet) - and those issues would be addressed in the next version as well.

@ghost
Copy link
Author

ghost commented Dec 22, 2017

Thanks for your response. I'll try to implement the ngModel and create a pull request. Hopefully my time will allow this wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant