diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5efb58019..81bef6294 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
- UI fix for the main graph on mobile overlapping its tick items on both axis
- UI fixes for text not showing properly in bars across multiple lines. This hides the totals on <768px and only shows the uniques and % to accommodate the goals text too. Larger screens still truncate as usual.
- Turn off autocomplete for name and password inputs in the _New shared link_ form.
+- Details modals are now responsive and take up less horizontal space on smaller screens to make it easier to scroll.
### Removed
- Removes AppSignal monitoring package
diff --git a/assets/css/modal.css b/assets/css/modal.css
index 2a36314ef..a87b55f76 100644
--- a/assets/css/modal.css
+++ b/assets/css/modal.css
@@ -31,7 +31,7 @@
bottom: 0;
background: rgba(0,0,0,0.6);
z-index: 99;
- overflow-x: hidden;
+ overflow-x: auto;
overflow-y: auto;
}
diff --git a/assets/js/dashboard/stats/modals/countries.js b/assets/js/dashboard/stats/modals/countries.js
index 0e833389a..0442aaa70 100644
--- a/assets/js/dashboard/stats/modals/countries.js
+++ b/assets/js/dashboard/stats/modals/countries.js
@@ -5,7 +5,6 @@ import Datamap from 'datamaps'
import Modal from './modal'
import * as api from '../../api'
import numberFormatter from '../../number-formatter'
-import Bar from '../bar'
import {parseQuery} from '../../query'
class CountriesModal extends React.Component {
@@ -22,6 +21,10 @@ class CountriesModal extends React.Component {
.then((res) => this.setState({loading: false, countries: res}))
}
+ label() {
+ return this.state.query.period === 'realtime' ? 'Current visitors' : 'Visitors'
+ }
+
renderCountry(country) {
const query = new URLSearchParams(window.location.search)
query.set('country', country.name)
@@ -33,7 +36,11 @@ class CountriesModal extends React.Component {
return (
diff --git a/assets/js/dashboard/stats/modals/modal.js b/assets/js/dashboard/stats/modals/modal.js
index cd6603baa..bfc6fe832 100644
--- a/assets/js/dashboard/stats/modals/modal.js
+++ b/assets/js/dashboard/stats/modals/modal.js
@@ -2,12 +2,22 @@ import React from "react";
import { createPortal } from "react-dom";
import { withRouter } from 'react-router-dom';
+// This corresponds to the 'md' breakpoint on TailwindCSS.
+const MD_WIDTH = 768;
+// We assume that the dashboard is by default opened on a desktop. This is also a fall-back for when, for any reason, the width is not ascertained.
+const DEFAULT_WIDTH = 1080;
+
+
class Modal extends React.Component {
constructor(props) {
super(props)
+ this.state = {
+ viewport: DEFAULT_WIDTH,
+ }
this.node = React.createRef()
this.handleClickOutside = this.handleClickOutside.bind(this)
this.handleKeyup = this.handleKeyup.bind(this)
+ this.handleResize = this.handleResize.bind(this)
}
componentDidMount() {
@@ -15,6 +25,8 @@ class Modal extends React.Component {
document.body.style.height = '100vh';
document.addEventListener("mousedown", this.handleClickOutside);
document.addEventListener("keyup", this.handleKeyup);
+ window.addEventListener('resize', this.handleResize, false);
+ this.handleResize();
}
componentWillUnmount() {
@@ -22,6 +34,7 @@ class Modal extends React.Component {
document.body.style.height = null;
document.removeEventListener("mousedown", this.handleClickOutside);
document.removeEventListener("keyup", this.handleKeyup);
+ window.removeEventListener('resize', this.handleResize, false);
}
handleClickOutside(e) {
@@ -38,16 +51,43 @@ class Modal extends React.Component {
}
}
+ handleResize() {
+ this.setState({ viewport: window.innerWidth });
+ }
+
close() {
this.props.history.push(`/${encodeURIComponent(this.props.site.domain)}${this.props.location.search}`)
}
+ /**
+ * @description
+ * Decide whether to set max-width, and if so, to what.
+ * If no max-width is available, set width instead to min-content such that we can rely on widths set on th.
+ * On >md, we use the same behaviour as before: set width to 800 pixels.
+ * Note that When a max-width comes from the parent component, we rely on that *always*.
+ */
+ getStyle() {
+ const { maxWidth } = this.props;
+ const { viewport } = this.state;
+ const styleObject = {};
+ if (maxWidth) {
+ styleObject.maxWidth = maxWidth;
+ } else {
+ styleObject.width = viewport <= MD_WIDTH ? "min-content" : "860px";
+ }
+ return styleObject;
+ }
+
render() {
return createPortal(