fix(components): [input] fix formatter and parse problem (#12622)

* fix(components): [input] fix formatter and parse problem

closed #12613

* fix(components): [input] fix input value problem

* fix(components): [input] update return value for input event emit

* test(components): [input] add test for formatter and parser
This commit is contained in:
wzc520pyfm
2023-06-04 13:51:44 +08:00
committed by GitHub
parent bac64b4801
commit 03e2a15411
2 changed files with 10 additions and 4 deletions

View File

@ -371,8 +371,11 @@ const onceInitSizeTextarea = createOnceInitResize(resizeTextarea)
const setNativeInputValue = () => {
const input = _ref.value
if (!input || input.value === nativeInputValue.value) return
input.value = nativeInputValue.value
const formatterValue = props.formatter
? props.formatter(nativeInputValue.value)
: nativeInputValue.value
if (!input || input.value === formatterValue) return
input.value = formatterValue
}
const handleInput = async (event: Event) => {
@ -382,7 +385,6 @@ const handleInput = async (event: Event) => {
if (props.formatter) {
value = props.parser ? props.parser(value) : value
value = props.formatter(value)
}
// should not emit input during composition