mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
34 lines
680 B
TypeScript
34 lines
680 B
TypeScript
import React, { MouseEvent } from "react";
|
|
import Button, { ButtonProps } from "./Button";
|
|
|
|
type SubmitButtonProps = ButtonProps & {
|
|
scrollToTop: boolean;
|
|
};
|
|
|
|
class SubmitButton extends React.Component<SubmitButtonProps> {
|
|
static defaultProps = {
|
|
scrollToTop: true
|
|
};
|
|
|
|
render() {
|
|
const { action, scrollToTop } = this.props;
|
|
return (
|
|
<Button
|
|
type="submit"
|
|
color="primary"
|
|
{...this.props}
|
|
action={(event: MouseEvent) => {
|
|
if (action) {
|
|
action(event);
|
|
}
|
|
if (scrollToTop) {
|
|
window.scrollTo(0, 0);
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default SubmitButton;
|