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 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() } } 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)