Skip to content

[fix] - first aria-slider has different stepper when used manually vs with keyboard #256

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions js/modules/enable-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,19 @@ const enableSlider = function (
);
});

$handle.addEventListener('touchstart', (e) => {
return this.handlePointerDown(
$handle,
$incrementor,
$decrementor,
e,
);
});
// Use passive: true for touchstart event listeners
$handle.addEventListener(
'touchstart',
(e) => {
return this.handlePointerDown(
$handle,
$incrementor,
$decrementor,
e,
);
},
{ passive: true },
);

window.addEventListener('resize', this.handleResize);

Expand Down Expand Up @@ -866,6 +871,10 @@ const enableSlider = function (
);
}

// Snap the value to the nearest increment
newVal = Math.round(newVal / this.inc) * this.inc;

// Clamp the value within the allowed range
newVal = Math.max(startVal, Math.min(newVal, stopVal));

this.positionHandle($handle, $handleButton, newVal);
Expand Down
25 changes: 17 additions & 8 deletions js/modules/es4/enable-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,19 @@ const enableSlider = function (
);
});

$handle.addEventListener('touchstart', (e) => {
return this.handlePointerDown(
$handle,
$incrementor,
$decrementor,
e,
);
});
// Use passive: true for touchstart event listeners
$handle.addEventListener(
'touchstart',
(e) => {
return this.handlePointerDown(
$handle,
$incrementor,
$decrementor,
e,
);
},
{ passive: true },
);

window.addEventListener('resize', this.handleResize);

Expand Down Expand Up @@ -861,6 +866,10 @@ const enableSlider = function (
);
}

// Snap the value to the nearest increment
newVal = Math.round(newVal / this.inc) * this.inc;

// Clamp the value within the allowed range
newVal = Math.max(startVal, Math.min(newVal, stopVal));

this.positionHandle($handle, $handleButton, newVal);
Expand Down