Skip to content

Commit 382a638

Browse files
authored
[core] fix(Button): always exit active state if blurred (#4309)
1 parent fb8014c commit 382a638

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/core/src/components/button/abstractButton.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export abstract class AbstractButton<H extends React.HTMLAttributes<HTMLElement>
127127
return {
128128
className,
129129
disabled,
130+
onBlur: this.handleBlur,
130131
onClick: disabled ? undefined : this.props.onClick,
131132
onKeyDown: this.handleKeyDown,
132133
onKeyUp: this.handleKeyUp,
@@ -162,6 +163,13 @@ export abstract class AbstractButton<H extends React.HTMLAttributes<HTMLElement>
162163
this.props.onKeyUp?.(e);
163164
};
164165

166+
protected handleBlur = (e: React.FocusEvent<any>) => {
167+
if (this.state.isActive) {
168+
this.setState({ isActive: false });
169+
}
170+
this.props.onBlur?.(e);
171+
};
172+
165173
protected renderChildren(): React.ReactNode {
166174
const { children, icon, loading, rightIcon, text } = this.props;
167175
return [

0 commit comments

Comments
 (0)