Files
SCM-Manager/scm-ui-components/packages/ui-components/src/buttons/SubmitButton.js

35 lines
663 B
JavaScript
Raw Normal View History

//@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
};
render() {
2019-03-05 16:31:41 +01:00
const { action, scrollToTop } = this.props;
return (
<Button
type="submit"
color="primary"
{...this.props}
action={(event) => {
if (action) {
2019-03-05 16:31:41 +01:00
action(event);
}
if (scrollToTop) {
window.scrollTo(0, 0);
}
}}
/>
);
}
}
export default SubmitButton;