wangzuo / input-moment

React datetime picker powered by momentjs
https://wangzuo.github.io/input-moment
ISC License
526 stars 172 forks source link

No "Pass-Through" Props (eg. className, id, style) on InputMoment #48

Closed machineghost closed 7 years ago

machineghost commented 7 years ago

Currently if you do:

<InputMoment className="foo" id="bar" style={{display: none}} />

it behave the exact same as:

<InputMoment />

It would be nice if InputMoment could take those three as props, and then pass them along as props to the first element it renders (<div className="m-input-moment">). Of course, since that element already has a className, you'd want to combine them somehow ...

const className = (this.props.className || '') + ' m-input-moment';
return <div className={className} id={this.props.id} style={this.props.style}>

Adding this functionality would help make it easier to hide/show the calendar in response to an input being focused (a common pattern), and would just make the library more flexible in general.

Thanks for considering this.

brunocoelho commented 7 years ago

This is arguably super useful, I was trying to do it a couple of minutes ago, unfortunately I'll have to copy/paste a bunch of styles.

Something similar to this: https://github.com/moroshko/react-autosuggest#inputPropsProp

wangzuo commented 7 years ago

The fix is available in 0.3.2 now.

brunocoelho commented 7 years ago

Cool @wangzuo