Problem/Motivation

The new implementation with the range-slider-element behaviour conflicts with step validation for range inputs. Instead of rounding steps relative to the min attribute (the step base), it does so relative to 0.
This causes range sliders to snap to incorrect values when min is not a multiple of step, violating the HTML5 specification and providing unexpected user experience.

Steps to reproduce

Create a slider using these attributes:

$form['slider'] = [
  '#type' => 'range_slider',
  '#min' => 5,
  '#max' => 30,
  '#step' => 2,
  '#default_value' => 6,
];

Results in:

element is not a valid number

Proposed resolution

See if the issue can be fixed upstream first https://github.com/andreruffert/range-slider-element/pull/210

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#4 Screenshot 2025-09-21 at 16.37.39.png111.56 KBbaikho
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

baikho created an issue. See original summary.

baikho’s picture

Title: Step Validation Bug » Step rounding to use min as step base instead of 0
baikho’s picture

Parent issue: » #3516294: [META] 3.0.0 Plan
baikho’s picture

Title: Step rounding to use min as step base instead of 0 » Step rounding to use min as step base (element is not a valid number)
Issue summary: View changes
StatusFileSize
new111.56 KB
baikho’s picture

Issue summary: View changes
baikho’s picture

Issue summary: View changes
baikho’s picture

Priority: Normal » Major
baikho’s picture

Issue summary: View changes

  • baikho committed 7422aa32 on 3.x
    [#3547819] fix: Step rounding to use min as step base (element is not a...
baikho’s picture

Status: Active » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.