Skip to content

Commit

Permalink
fix(input): focus,blur double trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
carolin913 committed Jul 15, 2024
1 parent d100973 commit b9f0b98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/input/_example/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}}
/>
<t-input
Expand Down
3 changes: 3 additions & 0 deletions src/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class Input extends Component<InputProps> {
eventProps;

private handleChange = (e) => {
e.stopImmediatePropagation();
const { maxlength, maxcharacter, allowInputOverMax, status, onValidate, onChange } = this.props;

const { getValueByLimitNumber } = useLengthLimit({
Expand Down Expand Up @@ -137,6 +138,7 @@ export default class Input extends Component<InputProps> {
};

private handleFocus = (e: FocusEvent) => {
e.stopImmediatePropagation();
const { readonly, onFocus } = this.props;
if (readonly) return;
const { currentTarget }: { currentTarget: any } = e;
Expand All @@ -146,6 +148,7 @@ export default class Input extends Component<InputProps> {
};

private handleBlur = (e: FocusEvent) => {
e.stopImmediatePropagation();
const { readonly, onBlur } = this.props;
if (readonly) return;
const { currentTarget }: { currentTarget: any } = e;
Expand Down

0 comments on commit b9f0b98

Please sign in to comment.