Dogfalo/materialize · error · Error

noUiSlider: 'fixed' behaviour must be used with 2 handles

Error message

noUiSlider: 'fixed' behaviour must be used with 2 handles

What it means

The 'fixed' behaviour makes two handles move in lockstep and is enforced via testMargin(start[1]-start[0]). Because it needs a pair of handles to lock together, noUiSlider rejects it when the slider does not have exactly 2 handles.

Source

Thrown at extras/noUiSlider/nouislider.js:684

    function testBehaviour ( parsed, entry ) {

        // Make sure the input is a string.
        if ( typeof entry !== 'string' ) {
            throw new Error("noUiSlider: 'behaviour' must be a string containing options.");
        }

        // Check if the string contains any keywords.
        // None are required.
        var tap = entry.indexOf('tap') >= 0;
        var drag = entry.indexOf('drag') >= 0;
        var fixed = entry.indexOf('fixed') >= 0;
        var snap = entry.indexOf('snap') >= 0;
        var hover = entry.indexOf('hover') >= 0;

        if ( fixed ) {

            if ( parsed.handles !== 2 ) {
                throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");
            }

            // Use margin to enforce fixed state
            testMargin(parsed, parsed.start[1] - parsed.start[0]);
        }

        parsed.events = {
            tap: tap || snap,
            drag: drag,
            fixed: fixed,
            snap: snap,
            hover: hover
        };
    }

    function testTooltips ( parsed, entry ) {

        if ( entry === false ) {

View on GitHub (pinned to 824e78248b)

Solutions

  1. Provide exactly two start values, e.g. start: [20, 80], when using 'fixed'.
  2. Remove 'fixed' from behaviour if you need 1 or 3+ handles (use 'drag' or 'tap' instead).
  3. Verify parsed.handles equals start.length before adding 'fixed' to the behaviour string.

Example fix

// before
noUiSlider.create(el, { start: [0], range:{min:0,max:100}, behaviour: 'drag-fixed' });
// after
noUiSlider.create(el, { start: [20, 80], range:{min:0,max:100}, behaviour: 'drag-fixed' });
Defensive patterns

Strategy: validation

Validate before calling

function assertFixedMatchesHandles(opts) {
  const handles = Array.isArray(opts.start) ? opts.start.length : 1;
  if (typeof opts.behaviour === 'string' && opts.behaviour.includes('fixed') && handles !== 2) {
    throw new Error("'fixed' behaviour requires exactly 2 start values");
  }
}

Type guard

function canUseFixed(opts) {
  const handles = Array.isArray(opts.start) ? opts.start.length : 1;
  return handles === 2;
}

Prevention

When it happens

Trigger: Call noUiSlider.create() with options.behaviour containing the substring 'fixed' AND options.start with a length other than 2 (which sets parsed.handles). For example start:[0] with behaviour 'drag-fixed', or start:[0,25,50] with behaviour 'fixed'.

Common situations: Adding 'fixed' to behaviour while keeping a single-handle or multi-handle config; changing the number of start values without updating behaviour; or copying a config snippet between sliders with different handle counts.

Related errors


AI-assisted analysis of Dogfalo/materialize@824e78248b (2026-08-13). Data as JSON: /api/errors/425a3ad98dddbbd6. Report an issue: GitHub.