Fomantic-ui: [Slider] onChange ran when initialized

Created on 5 Sep 2019  路  2Comments  路  Source: fomantic/Fomantic-UI

Bug Report

Steps to reproduce

  1. Create a slider with onChange method
  2. View the page

Expected result

Nothing should happen in the onChange method and the slider should be initialized as normal

Actual result

Slider is initialized but onChange is ran

Testcase

https://jsfiddle.net/jgwkd75c/

Screenshot

asbYBqd5Eu

Version

2.7.8

lanjavascript typbug

Most helpful comment

I always assumed this was a feature, dropdown does it too. I do see that a few other modules have a fireOnInit setting, but I'm not sure if it's working on the Rating module. https://jsfiddle.net/x8ue7dmq/

I think not calling onChange by default and offering a fireOnInit for every input would be the most consistent.

All 2 comments

This is because set.value() is ran in the read.settings() method here https://github.com/fomantic/Fomantic-UI/blob/develop/src/definitions/modules/slider.js#L1002

and read.settings() is ran in the initialize method here https://github.com/fomantic/Fomantic-UI/blob/develop/src/definitions/modules/slider.js#L112

I always assumed this was a feature, dropdown does it too. I do see that a few other modules have a fireOnInit setting, but I'm not sure if it's working on the Rating module. https://jsfiddle.net/x8ue7dmq/

I think not calling onChange by default and offering a fireOnInit for every input would be the most consistent.

Was this page helpful?
0 / 5 - 0 ratings