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

34 lines
651 B
TypeScript
Raw Normal View History

import React from 'react';
import Button, { ButtonProps } from './Button';
2019-03-05 16:31:41 +01:00
type SubmitButtonProps = ButtonProps & {
scrollToTop: boolean;
};
2019-03-05 16:31:41 +01:00
class SubmitButton extends React.Component<SubmitButtonProps> {
static defaultProps = {
scrollToTop: true,
2019-03-05 16:31:41 +01:00
};
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;