Skip to content

Slider double focus with a single value #71

@ctjhoa

Description

@ctjhoa

Hi,

A small bug report here,
With the Slider component and a single value.

eg.

<Slider
  defaultValue={2}
  min={0}
  max={4}
  step={1}
/>

You have a double Thumb focus zone due to this code:

const _values = React.useMemo(

There is no value, the defaultValue is not array so you fallback on the [min, max] part.

After a small ping pong with Gemini AI, it suggests me this instead:

  const _values = React.useMemo(() => {
    const prop = value ?? defaultValue;
    if (Array.isArray(prop)) return prop;
    return [prop ?? min];
  }, [value, defaultValue, min]);

However I'm not sure this is a valid solution (not having max anymore), I'd like your input on this to create a bugfix PR.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions