Skip to content

Commit

Permalink
navigation improvements
Browse files Browse the repository at this point in the history
 - use comma arrayFormat for URL params
 - preserve stickyMapId when only URL params change;
 - don't break if page only exists in base config
  • Loading branch information
sheppard committed Jul 22, 2021
1 parent e28e58e commit a524064
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,10 @@ function _getBaseConf(page) {

function _getConf(page, silentFail, baseConf) {
var conf = (baseConf ? app.config : app.wq_config).pages[page];
if (!conf && !baseConf) {
return _getConf(page, silentFail, true);
}

if (!conf) {
if (silentFail) {
return;
Expand Down
11 changes: 10 additions & 1 deletion packages/map/src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ export default function reducer(state = {}, action, config) {
if (routeInfo === _lastRouteInfo) {
return state;
} else {
const isSameView =
_lastRouteInfo &&
routeInfo.template &&
routeInfo.template === _lastRouteInfo.template;
_lastRouteInfo = routeInfo;
let nextState = {};
const { stickyMaps } = state;
const { stickyMaps, stickyMapId } = state;
if (!conf) {
nextState = { stickyMaps };
} else {
Expand All @@ -42,12 +46,17 @@ export default function reducer(state = {}, action, config) {
highlight,
instance,
mapId,
stickyMapId:
isSameView && stickyMapId === mapId ? mapId : null,
stickyMaps
};
}
if (!nextState.stickyMaps) {
delete nextState.stickyMaps;
}
if (!nextState.stickyMapId) {
delete nextState.stickyMapId;
}
return nextState;
}
}
Expand Down
11 changes: 10 additions & 1 deletion packages/router/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ const HTML = '@@HTML',
[LAST]: true
};

const defaultQuerySerializer = {
parse(str) {
return queryString.parse(str, { arrayFormat: 'comma' });
},
stringify(obj) {
return queryString.stringify(obj, { arrayFormat: 'comma' });
}
};

// Exported module object
var router = {
config: {
store: 'main',
tmpl404: 404,
debug: false,
getTemplateName: name => name,
querySerializer: queryString
querySerializer: defaultQuerySerializer
},
routesMap: {},
routeInfoFn: [],
Expand Down

0 comments on commit a524064

Please sign in to comment.