2018-09-03 16:17:36 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import Button, { type ButtonProps } from "./Button";
|
|
|
|
|
|
2019-03-05 16:31:41 +01:00
|
|
|
type SubmitButtonProps = ButtonProps & {
|
|
|
|
|
scrollToTop: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SubmitButton extends React.Component<SubmitButtonProps> {
|
|
|
|
|
static defaultProps = {
|
|
|
|
|
scrollToTop: true
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-03 16:17:36 +02:00
|
|
|
render() {
|
2019-03-05 16:31:41 +01:00
|
|
|
const { action, scrollToTop } = this.props;
|
2019-02-15 15:32:54 +01:00
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
color="primary"
|
|
|
|
|
{...this.props}
|
2019-02-20 09:47:35 +01:00
|
|
|
action={(event) => {
|
|
|
|
|
if (action) {
|
2019-03-05 16:31:41 +01:00
|
|
|
action(event);
|
|
|
|
|
}
|
|
|
|
|
if (scrollToTop) {
|
|
|
|
|
window.scrollTo(0, 0);
|
2019-02-20 09:47:35 +01:00
|
|
|
}
|
2019-02-15 15:32:54 +01:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2018-09-03 16:17:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SubmitButton;
|