From b9f0b983a09cec2e01f0459e8f869c66ca41611f Mon Sep 17 00:00:00 2001 From: carolin913 Date: Mon, 15 Jul 2024 18:39:22 +0800 Subject: [PATCH] fix(input): focus,blur double trigger --- src/input/_example/base.tsx | 8 +++++++- src/input/input.tsx | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/input/_example/base.tsx b/src/input/_example/base.tsx index 95f7872..07b0509 100644 --- a/src/input/_example/base.tsx +++ b/src/input/_example/base.tsx @@ -15,7 +15,13 @@ export default class InputBase extends Component { placeholder="请输入内容(无默认值)" onChange={(value) => { this.value1 = value; - console.log(value); + console.log('change', value); + }} + onFocus={() => { + console.log('focus'); + }} + onBlur={() => { + console.log('blur'); }} /> { eventProps; private handleChange = (e) => { + e.stopImmediatePropagation(); const { maxlength, maxcharacter, allowInputOverMax, status, onValidate, onChange } = this.props; const { getValueByLimitNumber } = useLengthLimit({ @@ -137,6 +138,7 @@ export default class Input extends Component { }; private handleFocus = (e: FocusEvent) => { + e.stopImmediatePropagation(); const { readonly, onFocus } = this.props; if (readonly) return; const { currentTarget }: { currentTarget: any } = e; @@ -146,6 +148,7 @@ export default class Input extends Component { }; private handleBlur = (e: FocusEvent) => { + e.stopImmediatePropagation(); const { readonly, onBlur } = this.props; if (readonly) return; const { currentTarget }: { currentTarget: any } = e;