From 05afd2cf4989eecc061058e0a599e1c107e3fbd3 Mon Sep 17 00:00:00 2001 From: Vignesh Joglekar Date: Mon, 21 Dec 2020 01:29:10 -0600 Subject: [PATCH 1/3] Navigates to day when same day is chosen in flatpickr --- assets/js/dashboard/datepicker.js | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/assets/js/dashboard/datepicker.js b/assets/js/dashboard/datepicker.js index a4521012777d..d4045257b4cd 100644 --- a/assets/js/dashboard/datepicker.js +++ b/assets/js/dashboard/datepicker.js @@ -223,16 +223,29 @@ class DatePicker extends React.Component { setCustomDate(dates) { if (dates.length === 2) { const [from, to] = dates - navigateToQuery( - this.props.history, - this.props.query, - { - period: 'custom', - date: false, - from: formatISO(from), - to: formatISO(to), - } - ) + if (formatISO(from) === formatISO(to)) { + navigateToQuery( + this.props.history, + this.props.query, + { + period: 'day', + date: formatISO(from), + from: false, + to: false, + } + ) + } else { + navigateToQuery( + this.props.history, + this.props.query, + { + period: 'custom', + date: false, + from: formatISO(from), + to: formatISO(to), + } + ) + } this.close() } } From 7a29bb1e1c7fd3c2ae012d8494d13aabd6403ed3 Mon Sep 17 00:00:00 2001 From: Vignesh Joglekar Date: Mon, 21 Dec 2020 01:29:40 -0600 Subject: [PATCH 2/3] Ensures that erroneous from and to params are removed when re-navigating --- assets/js/dashboard/query.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.js index 32c7d5f6b8f7..fcd65dafc56b 100644 --- a/assets/js/dashboard/query.js +++ b/assets/js/dashboard/query.js @@ -46,6 +46,8 @@ export function parseQuery(querystring, site) { function generateQueryString(data) { const query = new URLSearchParams(window.location.search) query.delete("date"); + query.delete("from"); + query.delete("to"); Object.keys(data).forEach(key => { if (!data[key]) { query.delete(key) From f9e64def91b1fe89a49b3c25421c6311f6037b06 Mon Sep 17 00:00:00 2001 From: Vignesh Joglekar Date: Mon, 21 Dec 2020 01:33:32 -0600 Subject: [PATCH 3/3] Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e1425a83fe8..ea39502706ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ All notable changes to this project will be documented in this file. - Fix URL decoding in query parameters plausible/analytics#416 - Fix overly-sticky date in query parameters plausible/analytics/#439 - Prevent picking dates before site insertion plausible/analtics#446 +- Fix overly-sticky from and to in query parameters plausible/analytics#495 +- Adds support for single-day date selection plausible/analytics#495 ### Security - Do not run the plausible Docker container as root plausible/analytics#362