SubmitButton: scroll to top after performing action

This commit is contained in:
Philipp Czora
2019-02-20 09:47:35 +01:00
parent deedb573a6
commit 90cb047ccb

View File

@@ -4,12 +4,16 @@ import Button, { type ButtonProps } from "./Button";
class SubmitButton extends React.Component<ButtonProps> { class SubmitButton extends React.Component<ButtonProps> {
render() { render() {
const { action } = this.props;
return ( return (
<Button <Button
type="submit" type="submit"
color="primary" color="primary"
{...this.props} {...this.props}
action={() => { action={(event) => {
if (action) {
action(event)
}
window.scrollTo(0, 0); window.scrollTo(0, 0);
}} }}
/> />