react-autocomplete icon indicating copy to clipboard operation
react-autocomplete copied to clipboard

Make wrapper-element configurable

Open flash1293 opened this issue 7 years ago • 5 comments

This PR uses a span as the wrapping element instead of a div. This makes it possible to use the component inside of elements which prohibit the usage of block-elements as children like paragraphs.

Example:

<p><Autocomplete {/*...*/} /></p>

Prodcues the error <div> cannot appear as a descendant of <p>. See ... > Autocomplete > div.

Tests are not adjusted, I will add them tomorrow.

flash1293 avatar Feb 08 '18 13:02 flash1293

Hi Johannes! I think I'd rather wait for something like https://github.com/reactjs/react-autocomplete/issues/298 instead of changing the root node type, as this will likely cause problems for people who rely on the rapper being a <div>. If you feel like having an attempt at implementing the that suggestion it would be greatly appreciated.

CMTegner avatar Feb 11 '18 10:02 CMTegner

Fair enough - what about a new prop renderWrapper analogous to renderInput and renderMenu? It would be a function with the parameters wrapperProps, wrapperStyle, renderedInput and renderedMenu, default is something like

return <div style={{wrapperStyle}} {...wrapperProps}>
{renderedInput}
{renderedMenu}
</div>;

Pros:

  • no breaking change
  • #298 covered
  • even more flexibility for the consumer

Would be happy to adjust the PR if you agree.

flash1293 avatar Feb 11 '18 13:02 flash1293

Sounds good! I wonder if maybe we should rather pass in renderInput and renderMenu in addition to isOpen, so you have full control over what you want to render.

CMTegner avatar Feb 24 '18 17:02 CMTegner

@CMTegner I added the renderWrapper prop. I'm not sure what you mean by full control. With open, renderMenu, renderInput and now renderWrapper, the user should be in complete control of the render-output.

flash1293 avatar Feb 25 '18 09:02 flash1293

y no merge?

bitionaire avatar Apr 24 '18 07:04 bitionaire