From df1f043a49a12dce537a3b5b9cf737a405f8ae59 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <256895@studenti.unimore.it> Date: Sat, 8 May 2021 00:35:13 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20reloading=20on=20enter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/interactive/BoxConditionDatetime.js | 7 +++++-- .../src/components/interactive/BoxConditionHashtag.js | 7 +++++-- .../src/components/interactive/BoxConditionUser.js | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/code/frontend/src/components/interactive/BoxConditionDatetime.js b/code/frontend/src/components/interactive/BoxConditionDatetime.js index 75b6157..2a1b9b5 100644 --- a/code/frontend/src/components/interactive/BoxConditionDatetime.js +++ b/code/frontend/src/components/interactive/BoxConditionDatetime.js @@ -35,7 +35,7 @@ export default function BoxConditionDatetime({ ...props }) { return setDatetime(text) } - const onButtonClick = () => { + const onButtonClick = e => { const naive = new Date(datetime) if(naive.toString() === "Invalid Date") { console.debug("Refusing to add condition: ", naive , " is an Invalid Date.") @@ -44,11 +44,14 @@ export default function BoxConditionDatetime({ ...props }) { const aware = convertToLocalISODate(naive) addCondition(new Condition("TIME", `${ba ? ">" : "<"} ${aware}`)) setDatetime("") + + // Prevent reloading the page! + e.preventDefault() } return ( Search by time period} {...props}> - + { + const onButtonClick = e => { addCondition(new Condition("HASHTAG", hashtag)) setHashtag("") + + // Prevent reloading the page! + e.preventDefault() } return ( Search by hashtag} {...props}> - + { + const onButtonClick = e => { addCondition(new Condition("USER", user)) setUser("") + + // Prevent reloading the page! + e.preventDefault() } return ( Search by user} {...props}> - +