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

Add formatter prop for InputNumber #5178

Merged
merged 1 commit into from
Mar 6, 2017
Merged

Add formatter prop for InputNumber #5178

merged 1 commit into from
Mar 6, 2017

Conversation

afc163
Copy link
Member

@afc163 afc163 commented Mar 6, 2017

@mention-bot
Copy link

@afc163, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjycui, @yesmeck and @yiminghe to be potential reviewers.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 64.358% when pulling 08c5fe2 on improve-input-number into d09d667 on master.

@yesmeck yesmeck merged commit 43280ea into master Mar 6, 2017
@yesmeck yesmeck deleted the improve-input-number branch March 6, 2017 03:40
@acomito
Copy link

acomito commented Mar 6, 2017

This is a great update. I just grabbed 2.8 to use this in my project, it's easy enough to add a $ to the front, but I'm trying to do comma separators. This is my setup and the resulting behavior:

http://g.recordit.co/cfwQuZYcpY.gif

It seems to work when numbers are added from the front, but if you type number into the input with cursor at the back of the number, you get some issues. Does this issue seem to be with the formatter callback or with my comma function?


const numberWithCommas = (x) => {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

<FormItem >
                  {getFieldDecorator('value', {
                    rules: [{ required: true, message: 'Please input your Value!' }],
                  })(
                    <InputNumber 
                      formatter={value => `$ ${numberWithCommas(value)}`}  
                      min={10000} 
                      max={10000000000} 
                    />
                  )}
                </FormItem>

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.

None yet

5 participants