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

Safari numeric input not allowing decimals #167

Closed
todda00 opened this issue Jan 19, 2017 · 7 comments
Closed

Safari numeric input not allowing decimals #167

todda00 opened this issue Jan 19, 2017 · 7 comments
Assignees
Labels
Type: Bug Bug reports and their fixes

Comments

@todda00
Copy link
Contributor

todda00 commented Jan 19, 2017

Strange issue here with Safari and numeric inputs.

In Safari when adding a numeric field using AutoField, the decimal cannot be typed unless its at the beginning of the input. So I cannot type 1.5, but could type .5. but not 0.5 . Oddly, you can type 15 then cursor back and enter a decimal to get to 1.5 . Also, the arrows up and down do work, so if you enter 1, and arrow up, 1.01 is entered (my step is 0.01). Initially I thought this was a Safari oddity with type="number" fields, but I pasted the exact HTML generated from uniforms and added it directly, and Safari allows me to insert decimals.

Schema:

UTR: {
    type: Number,
    optional: true,
    min: 1,
    max: 17,
    decimal: true,
    label: 'UTR',
  },

Usage:

<AutoField name="UTR" grid={{ xs: 6 }} inputClassName="form-control-sm" />

This generates the HTML:

<input type="number" class="form-control-sm form-control" id="uniforms-0000-0001" max="17" min="1" name="UTR" placeholder="" step="0.01">

When I add this HTML directly in the code outside of uniforms it works as expected, but not from the AutoField generated code.
safari_decimal

Chrome and Firefox do not have this issue, decimals can be entered as expected

@radekmie radekmie self-assigned this Jan 19, 2017
@radekmie radekmie added the Type: Bug Bug reports and their fixes label Jan 19, 2017
@radekmie
Copy link
Contributor

I'll try to investigate but I can't promise anything - the only Safari I can play with has no developer tools.

@radekmie
Copy link
Contributor

Maybe this might cause this issue. If so, it's even weirder that it happens only on Safari.

@radekmie
Copy link
Contributor

radekmie commented Jan 19, 2017

Yes, that is the cause. The only way I see is to rework NumField - it should have internal state of input (string) and call onChange only when parsed value changed, so 1 and 1.2 will be the same.

I'll leave it for now - if you see another way - please, let me know.

@todda00
Copy link
Contributor Author

todda00 commented Jan 23, 2017

Created a PR for this, targeting BS3 & BS4 - I don't know if this behavior exists in the other packages, I do not use semantic.

@radekmie
Copy link
Contributor

(ping) I didn't have much time recently and I probably won't in the next few days, but I guarantee, that I'll get to it within next two weeks. I'm planning to create another class which will be compatible with BaseField.

@todda00
Copy link
Contributor Author

todda00 commented Jan 30, 2017 via email

@radekmie
Copy link
Contributor

Well, it was almost two weeks, so I've implemented a modified version of your solution (thanks!), but it's not a future-proof solution. It's working as expected, but now NumField allows some weird inputs like &(), but it's browser dependent - it's quite OK on Chrome, Firefox and Safari - if the user will enter correct value, then it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

No branches or pull requests

2 participants