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

Spinner - improve initial value

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 8.0.4.2
    • Fix Version/s: 8.5.2
    • Component/s: Components
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                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