felixakiragreen / react-kronos

A fast, intuitive, and elegant date and time picker for React.
https://felixakiragreen.github.io/react-kronos/
MIT License
90 stars 28 forks source link

Expose validation result in `onSelect` #44

Closed KCraw closed 7 years ago

KCraw commented 8 years ago

When controlling visibility, there is currently no way to know whether validation succeeded or failed when props.onSelect is called.

The internal onSelect uses toggles state.visible; however, if you have enabled controlVisibility, this will be out of sync with the actual visibility.

The props.onSelect callback should set the appropriate visibility, but it would be nice to know whether the validation succeeded or not.

felixakiragreen commented 8 years ago

Would you like for this to be a parameter in the callback? For example change: https://github.com/dubert/react-kronos/blob/master/src/index.js#L342

to:

if (this.props.onSelect) this.props.onSelect(datetime, willBeVisible, didValidate)

(and obviously define the didValidate variable)

KCraw commented 8 years ago

Yeah, that would be great. That way we can follow similar logic to the default of not closing the input if it was somehow invalid. Thanks!

On Thu, Sep 15, 2016 at 12:35 PM, Luke Dubert notifications@github.com wrote:

Would you like for this to be a parameter in the callback? For example change: https://github.com/dubert/react-kronos/blob/master/src/ index.js#L342

to:

if (this.props.onSelect) this.props.onSelect(datetime, willBeVisible, didValidate)

(and obviously define the didValidate variable)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dubert/react-kronos/issues/44#issuecomment-247396932, or mute the thread https://github.com/notifications/unsubscribe-auth/AHs6LVuYe6fQzwDGYqLUQ4XjzbqX3Mltks5qqYHpgaJpZM4J5Lk3 .

felixakiragreen commented 7 years ago

Just released 1.6.0!

onSelect will now include (datetime, visible, shouldClose). shouldClose will inform you whether it validated.