Skip to content

Commit

Permalink
Don't use autoFocus prop, as apparently it can reduce usability and a…
Browse files Browse the repository at this point in the history
…ccessibility (jsx-a11y/no-autofocus)
  • Loading branch information
johnnyoshika committed Oct 6, 2020
1 parent 6e037e0 commit 220cee0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/contact-us/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react'
import React, { useEffect, useRef } from 'react'
import Layout from '../../components/layout'

import './styles.css'

const ContactPage = () => {
const nameInput = useRef(null)

useEffect(() => {
if (nameInput.current) nameInput.current.focus()
}, [])

return (
<Layout title="Contact">
<form
Expand All @@ -15,12 +21,12 @@ const ContactPage = () => {
>
{/* The `form-name` hidden field is required to support form submissions in Netlify without JavaScript */}
<input type="hidden" name="form-name" value="contact" />
<p class="hidden">
<div class="hidden">
<label>
Don’t fill this out if you're human:{' '}
<input name="bot-field" />
</label>
</p>
</div>
<div className="cf7-form">
<div className="clear margin-b15">
<div className="col-xs-12 col-sm-6 padding-l0 xs-p0">
Expand All @@ -31,7 +37,7 @@ const ContactPage = () => {
type="text"
name="name"
required="required"
autoFocus="autofocus"
ref={nameInput}
aria-required="true"
aria-invalid="false"
/>
Expand Down

0 comments on commit 220cee0

Please sign in to comment.