airbnb / rheostat

Rheostat is a www, mobile, and accessible slider component built with React
MIT License
1.69k stars 189 forks source link

DefaultHandle should allow children #274

Open timkelty opened 4 years ago

timkelty commented 4 years ago

I wanted to display the handle value, positioned below the handle.

The easiest way to do this seemed to be pass my own handle that rendered children with the label. eg:

const Handle = ({buttonOffset = 0, ...handleProps}) => {
  const value = handleProps['aria-valuenow'];

  return (
    <DefaultHandle {...handleProps}>
      <span
        style={{
          position: 'absolute',
          top: 30,
          left: 0,
          right: 0,
        }}
       >
        {value}
      </span>
    </DefaultHandle>
  );
};

Works great, except I get a propType warning, because DefaultHandle is expecting exact props:

Warning: Failed prop type: DefaultHandle: unknown props found: children

Seems like children could safely be added to it's allowed props?

ljharb commented 4 years ago

What if you wrap the DefaultHandle with a div instead?

timkelty commented 4 years ago

@ljharb definitely could, but I was trying to piggyback off the already positioned DefaultHandle, as I want to display the label right below the handles.