Skip to content

Commit

Permalink
fix(numeric):numeric 修复输入超大数字变为科学计数法时失焦后组件消失的问题 (#563)
Browse files Browse the repository at this point in the history
* fix(numeric):numeric 输入超大数字变为科学计数法时失焦后组件消失的问题

* fix(numeric):numeric 修改评审意见
  • Loading branch information
shonen7 authored Oct 11, 2023
1 parent 9507299 commit 2041a44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/renderless/src/common/bigInt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class BigIntDecimal {
const trimRet = trimNumber(mergedValue)
this.negative = trimRet.negative
const numbers = trimRet.trimStr.split('.')
this.integer = BigInt(numbers[0])
this.integer = numbers[0].indexOf('e') === -1 ? BigInt(numbers[0]) : numbers[0]
const decimalStr = numbers[1] || '0'
this.decimal = convertBigInt(decimalStr)
this.decimalLen = decimalStr.length
Expand Down
13 changes: 11 additions & 2 deletions packages/renderless/src/numeric/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export const increase =
}

const value = (props.mouseWheel ? state.displayValue : props.modelValue) || 0

if (value.toString().includes('e')) {
return
}

let newVal = api.internalIncrease({ val: value, step: props.step })

if (!props.circulate || !isFinite(props.max) || !isFinite(props.min)) {
Expand All @@ -116,8 +121,12 @@ export const decrease =
if (state.inputDisabled || state.minDisabled) {
return
}

const value = (props.mouseWheel ? state.displayValue : props.modelValue) || 0

if (value.toString().includes('e')) {
return
}

let newVal = api.internalDecrease({ val: value, step: props.step })

if (!props.circulate || !isFinite(props.max) || !isFinite(props.min)) {
Expand Down Expand Up @@ -269,7 +278,7 @@ export const handleInput =
emitError()

if (!(value === '' && props.allowEmpty)) {
value = state.lastInput
value = value.indexOf('e') === -1 ? state.lastInput : value
}
} else {
value = value
Expand Down

0 comments on commit 2041a44

Please sign in to comment.