Fixes couple of Flatpickr related issues (#495)

* Navigates to day when same day is chosen in flatpickr

* Ensures that erroneous from and to params are removed when re-navigating

* Changelog
This commit is contained in:
Vignesh Joglekar 2020-12-21 07:26:37 -06:00 committed by GitHub
parent df9767dbdc
commit 1174801255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 10 deletions

View File

@ -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

View File

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

View File

@ -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)