-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
- Do you want to request a feature or report a bug?
bug
- What is the current behavior?
The number
widget seems to suppress all characters that aren't digits, e
, .
, +
, -
, or ,
. (I assume the reason why e
and +
are allowed is to support exponential notation?)
However, these characters are also allowed for number
fields with a valueType
of int
. An attempt is made to sanitize them later, but it doesn't quite work and can lead to the field containing the string .nan
.
- If the current behavior is a bug, please provide the steps to reproduce.
- Add a number field to a collection:
-
label: MyNumberField
name: myNumberField
widget: number
valueType: int
- Create a new item in the collection
- Enter the text
123e
in the field - Press
1
Observe that the e
disappears and the 1
doesn't get added(?)
- Press
1
again
Observe that the 1
does get added this time.
- Press
e
twice, then1
Observe that ee
is left alone and the content is now 123ee1
- Click Publish
Observe that the save is rejected with a MYNUMBERFIELD IS REQUIRED.
message
- Change the value to
123..1
- Click Publish
Observe that the field gets persisted as:
myNumberField: .nan
- What is the expected behavior?
- That
,
,.
, ande
are suppressed whenvalueType
isint
. Alternatively that no keystrokes are suppressed and invalid numbers are dealt with when Publish is clicked. - That an accurate validation error is rendered when an invalid number has been entered
- That garbage like
.nan
is never persisted :) - Maybe that
e
,+
and,
aren't allowed at all, even whenvalueType
isfloat
or not specified. It seems unlikely that anyone would want to use exponential notation in a CMS.
- Please mention your versions where applicable.
Netlify CMS version: 1.9.2
Browser version: Chrome 67.0.3396.87/OSX
Node.JS version: 10.4.1
Operating System: Mac OSX 10.13.5 (High Sierra)