fix: 金额编辑器小数位溢出挤位 + 编辑页自动聚焦 + 周期账单移除冗余聚焦
This commit is contained in:
@@ -48,9 +48,19 @@ export function insertAmountKey(
|
||||
}
|
||||
|
||||
const normalizedInsert = normalizeInsert(value, safeCursor, key)
|
||||
const next = value.slice(0, safeCursor) + normalizedInsert + value.slice(safeCursor)
|
||||
let next = value.slice(0, safeCursor) + normalizedInsert + value.slice(safeCursor)
|
||||
|
||||
if (!isValidAmountInput(next, options)) {
|
||||
// 小数位超出上限时,从右侧挤出一个字符(小数部分左移)
|
||||
const dotIdx = next.indexOf('.')
|
||||
if (dotIdx >= 0 && next.length - dotIdx - 1 > MAX_DECIMAL_PLACES) {
|
||||
next = next.slice(0, -1)
|
||||
const newCursor = Math.min(safeCursor + normalizedInsert.length, next.length)
|
||||
if (!isValidAmountInput(next, options)) {
|
||||
return { value, cursorIndex: safeCursor, accepted: false }
|
||||
}
|
||||
return { value: next, cursorIndex: newCursor, accepted: true }
|
||||
}
|
||||
return { value, cursorIndex: safeCursor, accepted: false }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user