Skip to content

Commit

Permalink
feat(cleave): modify value isNaN check (#214)
Browse files Browse the repository at this point in the history
Co-authored-by: Austin Pratt <[email protected]>
  • Loading branch information
hargis32 and Austin Pratt authored Oct 25, 2023
1 parent 8e122a1 commit 88c45a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist/es/Cleave/Cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ var Cleave = /*#__PURE__*/function (_Component) {

_defineProperty(_assertThisInitialized(_this), "getRawValue", function () {
var pps = _this.properties;
console.log(pps);
var rawValue = pps.result;

if (pps.rawValueTrimPrefix) {
Expand Down Expand Up @@ -244,6 +245,7 @@ var Cleave = /*#__PURE__*/function (_Component) {

_defineProperty(_assertThisInitialized(_this), "onInput", function (value, fromProps, bypassSetState) {
var pps = _this.properties;
console.log(pps);
var _this$props = _this.props,
disabled = _this$props.disabled,
readOnly = _this$props.readOnly; // case 1: delete one more character "4"
Expand Down Expand Up @@ -279,7 +281,7 @@ var Cleave = /*#__PURE__*/function (_Component) {
// This mostly because we need to show user the native input placeholder
if (pps.prefix && pps.noImmediatePrefix && value.length === 0) {
pps.result = '';
} else if (readOnly || disabled && isNaN(Number(value))) {
} else if ((readOnly || disabled) && isNaN(Number(value))) {
pps.result = value;
return _this.updateValueState(false);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Cleave/Cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default class Cleave extends Component {
// This mostly because we need to show user the native input placeholder
if (pps.prefix && pps.noImmediatePrefix && value.length === 0) {
pps.result = ''
} else if (readOnly || (disabled && isNaN(Number(value)))) {
} else if ((readOnly || disabled) && isNaN(Number(value))) {
pps.result = value
return this.updateValueState(false)
} else {
Expand Down

0 comments on commit 88c45a1

Please sign in to comment.