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

fix slider jumps to first value if value is not in stepsArray #626

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DominikFG
Copy link

As I used the slider with a stepsArray and an input to change the value, I found that if a value is entered in the input that's not in the stepsArray the slider jumps to its minimum value.

I changed it so that it jumps to the next higher value instead.

@codecov-io
Copy link

Codecov Report

Merging #626 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #626   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         950    951    +1     
=====================================
+ Hits          950    951    +1
Impacted Files Coverage Δ
src/rzslider.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93ada11...13a85ba. Read the comment docs.

if (step === modelValue) {
var lastStep = i > 0 ? this.options.stepsArray[i - 1] : 0;

if (step === modelValue || (modelValue > lastStep && modelValue < step)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some context require here, will you add comments here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a stepsArray is given in the options and the value is set from the outside to a value that is not part of the stepsArray, currently the slider will jump to the first element in the stepsArray. I changed it so that if the value is between two values the slider jumps to the higher value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this feature. However, could you add a test case for it?

@evestraw
Copy link

evestraw commented Sep 6, 2018

I also run into this issue when the ceil is not in the step interval the ceil could be overshot.

@ViieeS
Copy link

ViieeS commented Jan 22, 2019

I think we just need to respect enforceStep: false option when using stepsArray. This is old bug #410.

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

Successfully merging this pull request may close these issues.

None yet

6 participants