Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React/input currency pass event to callback #498

Merged
merged 7 commits into from
Mar 5, 2019

Conversation

clairesunstudio
Copy link
Contributor

@clairesunstudio clairesunstudio commented Mar 4, 2019

This pr allow passing events to the onChange callout function, so that it can differentiate how the value is getting changed, get the type of events applied to InputCurrency.
It also fixes up/down button NaN value when default is null
screen shot 2019-03-04 at 4 03 50 pm

This pr is to fix the bug in PFML Benefits Calculator:
npm link to calculator pr

@clairesunstudio
Copy link
Contributor Author

clairesunstudio commented Mar 4, 2019

This pr added parameter event type (and direction if any) to the InputCurrency onChange prop:
onChange(newValue, props.id) => onChange(newValue, props.id, type, direction)

const { showError, errorMsg } = validNumber(newValue, props.min, props.max);
context.updateState({ showError, errorMsg, value: toCurrency(newValue, 2) }, () => {
if (typeof props.onChange === 'function') {
props.onChange(newValue, props.id);
props.onChange(newValue, props.id, type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
props.onChange(newValue, props.id, type);
props.onChange(newValue, props.id, type, key);

@clairesunstudio clairesunstudio merged commit 1103bc4 into develop Mar 5, 2019
@avrilpearl avrilpearl deleted the react/InputCurrency-pass-event-to-callback branch March 5, 2019 18:11
@clairesunstudio clairesunstudio mentioned this pull request Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants