Skip to content

Commit

Permalink
Merge pull request #3769 from primefaces/issue-3768
Browse files Browse the repository at this point in the history
Slider: Accessibility and focus updates on drag
  • Loading branch information
tugcekucukoglu authored Mar 20, 2023
2 parents d0e4120 + eb1b742 commit f14b464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion components/slider/Slider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Slider.vue', () => {
});

it('should drag start and end', async () => {
await wrapper.vm.onDragStart({ preventDefault: () => {} });
await wrapper.vm.onDragStart({ preventDefault: () => {}, currentTarget: { focus: () => {} } });

expect(wrapper.find('.p-slider').classes()).toContain('p-slider-sliding');

Expand Down
17 changes: 3 additions & 14 deletions components/slider/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,12 @@ export default {
if (newValue < this.min) newValue = this.min;
else if (newValue >= this.max) newValue = this.max;
if (newValue > modelValue[1]) {
modelValue[1] = newValue;
this.handleIndex = 1;
} else {
modelValue[0] = newValue;
}
modelValue[0] = newValue;
} else {
if (newValue > this.max) newValue = this.max;
else if (newValue <= this.min) newValue = this.min;
if (newValue < modelValue[0]) {
modelValue[0] = newValue;
this.handleIndex = 0;
} else {
modelValue[1] = newValue;
}
modelValue[1] = newValue;
}
} else {
if (newValue < this.min) newValue = this.min;
Expand All @@ -199,6 +187,7 @@ export default {
this.handleIndex = index;
}
event.currentTarget.focus();
event.preventDefault();
},
onDrag(event) {
Expand Down

0 comments on commit f14b464

Please sign in to comment.