mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 14:05:44 +01:00
added option to disable scrollToTop
This commit is contained in:
@@ -2,9 +2,17 @@
|
||||
import React from "react";
|
||||
import Button, { type ButtonProps } from "./Button";
|
||||
|
||||
class SubmitButton extends React.Component<ButtonProps> {
|
||||
type SubmitButtonProps = ButtonProps & {
|
||||
scrollToTop: boolean
|
||||
}
|
||||
|
||||
class SubmitButton extends React.Component<SubmitButtonProps> {
|
||||
static defaultProps = {
|
||||
scrollToTop: true
|
||||
};
|
||||
|
||||
render() {
|
||||
const { action } = this.props;
|
||||
const { action, scrollToTop } = this.props;
|
||||
return (
|
||||
<Button
|
||||
type="submit"
|
||||
@@ -12,9 +20,11 @@ class SubmitButton extends React.Component<ButtonProps> {
|
||||
{...this.props}
|
||||
action={(event) => {
|
||||
if (action) {
|
||||
action(event)
|
||||
action(event);
|
||||
}
|
||||
if (scrollToTop) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
window.scrollTo(0, 0);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user