From c93cdb1e433b29af79612b77737e66f240be52bf Mon Sep 17 00:00:00 2001 From: Alexander Bell Date: Sun, 30 Sep 2018 13:56:21 +0200 Subject: [PATCH] scroll issue fixed --- src/components/Menu/Menu.js | 9 +++++++++ src/components/PasswordManager/Edit.js | 5 +++++ src/components/PasswordManager/New.js | 5 +++++ src/pages/Main.js | 2 +- src/pages/home/Home.js | 6 ++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/Menu/Menu.js b/src/components/Menu/Menu.js index 3bbf397..dfbf904 100644 --- a/src/components/Menu/Menu.js +++ b/src/components/Menu/Menu.js @@ -64,6 +64,15 @@ const Main = inject("rootStore") ( observer( this.sheet.detach() } + + componentDidUpdate() { + if(this.state.visible) { + //Scroll to top + window.scrollTo(0, 0); + } + } + + handleItemClick(e, { name }) { this.props.handleItemClick(name); diff --git a/src/components/PasswordManager/Edit.js b/src/components/PasswordManager/Edit.js index 9494763..17fab97 100644 --- a/src/components/PasswordManager/Edit.js +++ b/src/components/PasswordManager/Edit.js @@ -82,6 +82,11 @@ const Edit = inject("rootStore") ( observer( var login; var password; if(nextProps.open) { + if(window.innerWidth <= 700) { + //Scroll to top + window.scrollTo(0, 0); + } + url = nextProps.data[nextProps.editIndex].url; login = decrypt(nextProps.data[nextProps.editIndex].login, nextProps.encryptionkey); password = decrypt(nextProps.data[nextProps.editIndex].password, nextProps.encryptionkey); diff --git a/src/components/PasswordManager/New.js b/src/components/PasswordManager/New.js index 2c794e0..616fc45 100644 --- a/src/components/PasswordManager/New.js +++ b/src/components/PasswordManager/New.js @@ -78,6 +78,11 @@ const New = inject("rootStore") ( observer( componentWillReceiveProps(nextProps) { if(nextProps.open !== this.props.open) { + if(nextProps.open && window.innerWidth <= 700) { + //Scroll to top + window.scrollTo(0, 0); + } + //Empty input fields this.setState({ url: '', diff --git a/src/pages/Main.js b/src/pages/Main.js index b00499a..147a25b 100644 --- a/src/pages/Main.js +++ b/src/pages/Main.js @@ -56,7 +56,7 @@ class Main extends Component { this.classes = classes; //Styles } - + componentWillUnmount() { this.sheet.detach() diff --git a/src/pages/home/Home.js b/src/pages/home/Home.js index 1bab6e3..c88e90b 100644 --- a/src/pages/home/Home.js +++ b/src/pages/home/Home.js @@ -2,6 +2,7 @@ import React, {Component} from 'react'; import jss from 'jss'; import preset from 'jss-preset-default'; import { Container } from 'semantic-ui-react'; +import history from '../../stores/functions/history'; /* * Functions import @@ -47,6 +48,11 @@ class Home extends Component { //Styles } + + componentDidMount() { + history.push('/'); + } + componentWillUnmount() { this.sheet.detach()