Skip to content

Commit 25ef0f8

Browse files
authored
Merge pull request #10148 from ethereum/fix-button-scroll
Fix button on click scroll
2 parents 056aaff + c93b4eb commit 25ef0f8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/components/Button/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export interface IProps extends ButtonProps {
88
}
99

1010
const Button: React.FC<IProps> = ({ toId, children, ...props }) => {
11-
const handleOnClick = () => {
12-
if (!toId) {
13-
return
11+
const handleOnClick = (e: React.MouseEvent<HTMLButtonElement>) => {
12+
if (toId) {
13+
scrollIntoView(toId)
1414
}
1515

16-
scrollIntoView(toId)
16+
props.onClick?.(e)
1717
}
1818

1919
return (
20-
<ChakraButton onClick={handleOnClick} {...props}>
20+
<ChakraButton {...props} onClick={handleOnClick}>
2121
{children}
2222
</ChakraButton>
2323
)

0 commit comments

Comments
 (0)