bootstrap-touchspin icon indicating copy to clipboard operation
bootstrap-touchspin copied to clipboard

Discussion about the behavior when initializing with an empty value

Open diesl opened this issue 3 years ago • 6 comments

The documentation on the website is outdated. Could you please update it?

At least all Settings and Events should be documented, adding more examples is not absolutely necessary.

Also, the used version of the touchspin library should be updated, it uses v3.0.1 from 28 May 2014 ...

diesl avatar Aug 24 '20 11:08 diesl

@istvan-ujjmeszaros One year has passed without any response. Is this project dead?

diesl avatar Oct 08 '21 07:10 diesl

@diesl good points under #106. I would be happy to improve the behavior, maybe by adding a new configuration parameter to set the behavior, defaulting to use the min value. But, on the other hand, I don't see a good use case to initialize the plugin with an empty value so I am just guessing what would be a suitable solution for everyone. These possibilities came to my mind:

  • min_or_max: Use the minimum value when the "+" button is clicked and the maximum value when the "-" button is clicked
  • min: Always use the minimum value when either button is clicked
  • max: Always use the maximum value when either button is clicked
  • midpoint: Always use the midpoint value when either button is clicked

If we default to midpoint then we can avoid a new breaking change and just have to update the documentation. What do you guys think?

Also, I am not sure what to do when only one or the other (meaning the min and max values) was being set.

istvan-ujjmeszaros avatar Apr 07 '23 10:04 istvan-ujjmeszaros

Just to note, the up and down buttons, the keyboard up/down arrows, and the mousewheel are all behaving consistent since the latest fixes are done (there are tests to make sure they all behave the same), so the behavior will be consistent across all methods of input.

istvan-ujjmeszaros avatar Apr 07 '23 10:04 istvan-ujjmeszaros

Thanks for picking this up again. Yes, I think it is a good idea to make this more flexible.

But, on the other hand, I don't see a good use case to initialize the plugin with an empty value

Not sure what exacltly you mean here.

These possibilities came to my mind:

Additionally, I would suggest the following:

  • a number (I think this is already implemented)
  • a function (to let the user create his own init value)

I still think midpoint is fairly exotic and could be solved with a custom function, but of course this would be a breaking change again. Could be done with a major version number change though.

Also, I am not sure what to do when only one or the other (meaning the min and max values) was being set.

I case of midpoint, you can not compute it. Fall back to existing min or max. If both are not set, fall back to 0.

diesl avatar Apr 08 '23 21:04 diesl

I also wanted to note that this ticket originally was far more general and not focused on one particular setting:

The documentation on the website is outdated. Could you please update it? At least all Settings and Events should be documented, adding more examples is not absolutely necessary. Also, the used version of the touchspin library should be updated, it uses v3.0.1 from 28 May 2014 ...

diesl avatar Apr 08 '23 21:04 diesl

I think that the settings and the events should be added to README.md too as this is quite obvious to update it when a new setting is being added. I will update the website too, but I am still thinking about what is the best way to do it (trying to come up with an automated way to populate the website with the latest version automagically - but I will update it manually in the next couple days). I have created #153 to be sure not to forget it.

istvan-ujjmeszaros avatar Apr 08 '23 22:04 istvan-ujjmeszaros