fix: Fix enter button click

This commit is contained in:
Medzik 2021-08-07 11:32:58 +00:00
parent 397411b341
commit fd11c3ade8
3 changed files with 21 additions and 6 deletions

View File

@ -0,0 +1 @@
@import 'react-notifications/lib/notifications.css'

View File

@ -1,17 +1,23 @@
import React from "react" import React from "react"
import AniLink from "gatsby-plugin-transition-link/AniLink" import AniLink from "gatsby-plugin-transition-link/AniLink"
import { NotificationManager, NotificationContainer } from 'react-notifications' import { NotificationManager, NotificationContainer } from "react-notifications"
import 'react-notifications/lib/notifications.css'
import Seo from "../components/seo" import Seo from "../components/seo"
import axios from "../axios" import axios from "../axios"
import "../css/base.sass" import "../css/base.sass"
import "../css/url.sass" import "../css/url.sass"
import "../css/notifications.sass"
const AddURLPage = () => { const AddURLPage = () => {
const [url, setURL] = React.useState('') const [url, setURL] = React.useState('')
const handleKeypress = e => {
if (e.charCode === 13 || e.keyCode === 13) {
addURL()
}
}
const changeURLHandler = event => { const changeURLHandler = event => {
const value = event.target.value const value = event.target.value
setURL(value) setURL(value)
@ -61,7 +67,8 @@ const AddURLPage = () => {
className="input" className="input"
placeholder="URL" placeholder="URL"
value={url} value={url}
onChange={changeURLHandler} /> onChange={changeURLHandler}
onKeyPress={handleKeypress} />
</div> </div>
<button <button

View File

@ -1,17 +1,23 @@
import React from "react" import React from "react"
import AniLink from "gatsby-plugin-transition-link/AniLink" import AniLink from "gatsby-plugin-transition-link/AniLink"
import { NotificationManager, NotificationContainer } from 'react-notifications' import { NotificationManager, NotificationContainer } from "react-notifications"
import 'react-notifications/lib/notifications.css'
import Seo from "../components/seo" import Seo from "../components/seo"
import axios from "../axios" import axios from "../axios"
import "../css/base.sass" import "../css/base.sass"
import "../css/url.sass" import "../css/url.sass"
import "../css/notifications.sass"
const DeleteURLPage = () => { const DeleteURLPage = () => {
const [url, setURL] = React.useState('') const [url, setURL] = React.useState('')
const handleKeypress = e => {
if (e.charCode === 13 || e.keyCode === 13) {
deleteURL()
}
}
const changeURLHandler = event => { const changeURLHandler = event => {
const value = event.target.value const value = event.target.value
setURL(value) setURL(value)
@ -63,7 +69,8 @@ const DeleteURLPage = () => {
className="input" className="input"
placeholder="URL" placeholder="URL"
value={url} value={url}
onChange={changeURLHandler} /> onChange={changeURLHandler}
onKeyPress={handleKeypress} />
</div> </div>
<button <button