Skip to content

Commit

Permalink
Fixes couple of Flatpickr related issues (plausible#495)
Browse files Browse the repository at this point in the history
* Navigates to day when same day is chosen in flatpickr

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

* Changelog
  • Loading branch information
Vigasaurus authored and oliver-kriska committed Dec 23, 2020
1 parent 8be1f82 commit 47ef657
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 23 additions & 10 deletions assets/js/dashboard/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
2 changes: 2 additions & 0 deletions assets/js/dashboard/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47ef657

Please sign in to comment.