tb / ng2-nouislider

Angular2 noUiSlider directive
http://tb.github.io/ng2-nouislider/
MIT License
185 stars 114 forks source link

Keyboard support handle issue when multi connect option is used. #230

Open pavandixit93 opened 3 years ago

pavandixit93 commented 3 years ago

Visit https://refreshless.com/nouislider/slider-options/#section-keyboard-support Go to Keyboard support example Focus the first slider thumb(slider handle) or Click on first slider thumb Now press right arrow key to move first slider towards second slider

Expected Result: It should move the slider handle and should stop once it reaches to second slider thumb since second slider thumb value is the max value for first slider thumb.

Actual Result: I use keyboard keys to slide the slider thumb it slides the first slider thumb even after reaching to next slider and after that it slides the both sliders. It works perfectly if I drag slider thumb using mouse.

This is very strange behavior please have a look. this is a production issue. By the way this works perfectly in https://refreshless.com/nouislider/slider-options/#section-keyboard-support

pavandixit93 commented 3 years ago

Hi Team, Since it was production issue, i did further debugging in library code and there i found the glitch. The issue is in function this.defaultKeyHandler. In this function it is not checked that the slider value is greater than or equal to the next slider value.

if(this.value[index]>=this.value[index+1] && sign!==-1){
   return;
 }

//this.value[index]>=this.value[index+1] if lower slider value is greater than or equal to upper slider value and user pressed Right Arrow key dont increase value and return from function. // sign!==-1 this is required so that if i decrease slider value by pressing Left Arrow key it should work. Here is the fix for that]

If i add above 3 lines of code after switch case defined inside this.defaultKeyHandler function it starts working fine. I can not add patch inside node_modules, I request you people to make this change and publish the changes.