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