Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3624

Spinner - improve initial value

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Normal Normal
    • 8.5.2
    • 8.0.4.2
    • Components
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      configure a spinner like this

      <spinner id="sp" constraint="min 1"/>
      

      The spinner value is initially empty (null value).
      Click the spinner up button

      Current Result

      The spinner shows the value 2

      Expected Result

      In such cases with a lower boundary (min constraint) it feels more usable to start with the lowest possible value if the value was previously empty.

      In this case after pressing up I'd expect to see the first possible value "1"

      When the lower bound is 0 or negative I'd expect to see the value "1" too
      For lower bounds > 0 I'd expect to see the lowest possible value.

      Debug Info

      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/Spinner.js#L120-L131

      Root Cause

      checkValue() determines the starting position in case of a null value which seems to do the expected.

      which is then followed by a call to de/increment the value (resulting in the unexpected value)
      if de/incrementing is skipped for a previously empty value that initializes into a non-zero value the usability could be improved giving more reasonable results.

      Workaround

      custom JS override

            CharlesQiu CharlesQiu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 3 hours, 30 minutes Remaining Estimate - 4 hours, 30 minutes
                4h 30m
                Logged:
                Time Spent - 3 hours, 30 minutes Remaining Estimate - 4 hours, 30 minutes
                3h 30m