Skip to content

Commit

Permalink
Firefox fixes (#1487)
Browse files Browse the repository at this point in the history
* Added UI fixes for firefox (web and mobile). Re-added temporary storing of timestamp selected by time slider input (so that its value is not reset by accidental mouseover of the history graph). This temporary value is now stored in redux state instead of internally in the slider component.

* Variable rename
  • Loading branch information
jkopb authored and corradio committed Jun 29, 2018
1 parent e885d81 commit cd78740
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions web/src/components/timeslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export default class TimeSlider {
}
}

selectedIndex(index) {
this._selectedIndex = index;
selectedIndex(index, previousIndex) {
this._selectedIndex = index || previousIndex;
this.render();
return this;
}
Expand Down
10 changes: 5 additions & 5 deletions web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,12 @@ if (typeof zoneMap !== 'undefined') {
zoneMap
.onSeaClick(() => {
dispatchApplication('showPageState', 'map'); // TODO(olc): infer in reducer?
dispatchApplication('selectedZoneName', undefined);
dispatch({type: 'UPDATE_SELECTED_ZONE', payload: {selectedZoneName: undefined}});
})
.onCountryClick((d) => {
dispatchApplication('isLeftPanelCollapsed', false);
dispatchApplication('showPageState', 'country'); // TODO(olc): infer in reducer?
dispatchApplication('selectedZoneName', d.countryCode);
dispatch({type: 'UPDATE_SELECTED_ZONE', payload: {selectedZoneName: d.countryCode}});
});
}

Expand Down Expand Up @@ -1066,7 +1066,7 @@ function renderHistory(state) {
.render();


zoneDetailsTimeSlider.onChange(selectedZoneTimeIndex => dispatchApplication('selectedZoneTimeIndex', selectedZoneTimeIndex)).render();
zoneDetailsTimeSlider.onChange(selectedZoneTimeIndex => dispatch({type: 'UPDATE_SLIDER_SELECTED_ZONE_TIME', payload: {selectedZoneTimeIndex: selectedZoneTimeIndex}})).render();

const firstDatetime = history[0] && moment(history[0].stateDatetime).toDate();
[countryHistoryCarbonGraph, countryHistoryPricesGraph, countryHistoryMixGraph].forEach((g) => {
Expand Down Expand Up @@ -1257,7 +1257,6 @@ observe(state => state.application.showPageState, (showPageState, state) => {
// Observe for zone change (for example after map click)
observe(state => state.application.selectedZoneName, (selectedZoneName, state) => {
if (!selectedZoneName) { return; }

// Analytics
thirdPartyServices.track('countryClick', { countryCode: selectedZoneName });

Expand All @@ -1266,6 +1265,7 @@ observe(state => state.application.selectedZoneName, (selectedZoneName, state) =
renderGauges(state);
renderContributors(state);
renderHistory(state);
zoneDetailsTimeSlider.selectedIndex(null, null);

// Fetch history if needed
tryFetchHistory(state);
Expand All @@ -1288,7 +1288,7 @@ observe(state => state.application.selectedZoneTimeIndex, (i, state) => {
renderCountryTable(state);
renderOpenTooltips(state);
[countryHistoryCarbonGraph, countryHistoryMixGraph, countryHistoryPricesGraph, zoneDetailsTimeSlider].forEach((g) => {
g.selectedIndex(i);
g.selectedIndex(i, state.application.previousSelectedZoneTimeIndex);
});
});
// Observe for color blind mode changes
Expand Down
18 changes: 18 additions & 0 deletions web/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const initialApplicationState = {
searchQuery: null,
selectedZoneName: null,
selectedZoneTimeIndex: null,
previousSelectedZoneTimeIndex: null,
solarEnabled: Cookies.get('solarEnabled') === 'true' || false,
useRemoteEndpoint: document.domain === '' || isLocalhost,
windEnabled: Cookies.get('windEnabled') === 'true' || false,
Expand Down Expand Up @@ -70,6 +71,23 @@ const applicationReducer = (state = initialApplicationState, action) => {
return state;
}

case 'UPDATE_SELECTED_ZONE': {
const { selectedZoneName } = action.payload;
return Object.assign(state, {
selectedZoneName,
selectedZoneTimeIndex: null,
previousSelectedZoneTimeIndex: null,
});
}

case 'UPDATE_SLIDER_SELECTED_ZONE_TIME': {
const { selectedZoneTimeIndex } = action.payload;
return Object.assign(state, {
selectedZoneTimeIndex,
previousSelectedZoneTimeIndex: selectedZoneTimeIndex,
});
}

default:
return state;
}
Expand Down
8 changes: 6 additions & 2 deletions web/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ body {
display: flex;
line-height: 1.2rem;
flex-direction: column;
height: 100%;
flex: 1;
overflow: hidden;
}

.mobile-info-tab {
Expand Down Expand Up @@ -1531,7 +1532,7 @@ sub {
width: 100%;
border-top: 1px solid lightgray;
text-align: center;
overflow-y: hidden;
overflow-y: visible;
}

.zone-time-slider .time-slider-axis-container{
Expand All @@ -1557,6 +1558,7 @@ sub {
background: transparent;
padding: 0;
overflow: visible;
border: none;
}

.time-slider-input:focus {
Expand Down Expand Up @@ -1751,6 +1753,8 @@ sub {
.country-panel {
margin: 0;
padding: 0 14px 0 20px;
-moz-user-select: none; /* Selection disabled on firefox to avoid android "select all" button popping up when pressing graphs */

}
.country-table-header {
position: relative;
Expand Down

0 comments on commit cd78740

Please sign in to comment.