Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contact us input focus #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/ContactUs/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import React from 'react'
//Importing TextField Material Ui element
import { TextField } from '@material-ui/core';

import { useStyles } from '../AddMissingPersonForm/UseStyles'

//This function is used to create the UI textField based on the assigned prps
//It is reusable as it can be imported and used at any form

export default function Input(props) {
const classes = useStyles();

//exporting the props recieved
const { name, label, value,error=null, onChange,multi } = props;
//returning the Ui TextField components either as a single or multiline
Expand All @@ -16,6 +20,7 @@ export default function Input(props) {
name={name}
value={value}
onChange={onChange}
className={classes.textFieldInput}
{...(error && {error:true,helperText:error})}
InputLabelProps={{style: {fontSize: 12}}} // font size of input label
inputProps={{style: {fontSize: 12}}} // font size of input text
Expand All @@ -30,6 +35,7 @@ export default function Input(props) {
rows={4}
variant="outlined"
onChange={onChange}
className={classes.textFieldInput}
{...(error && {error:true,helperText:error})}
InputLabelProps={{style: {fontSize: 12}}} // font size of input label
inputProps={{style: {fontSize: 12}}} // font size of input text
Expand Down
12 changes: 12 additions & 0 deletions src/components/ScrollToTop/ScrollToTop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

export default function ScrollToTop() {
const { pathname } = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

return null;
}
2 changes: 2 additions & 0 deletions src/router/RouterPages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import MissingPeople from '../pages/MissingPeople';
import ContactUs from '../pages/Contactus';
import PostMissingPerson from '../pages/PostMissingPerson';
import MissingPerson from '../pages/MissedPerson';
import ScrollToTop from '../components/ScrollToTop/ScrollToTop'

const RouterPages = () => {
return (
<Router>
<ScrollToTop/>
<Navbar />
<Switch>
<Route path="/" exact component={Home} />
Expand Down