Skip to content

Commit

Permalink
fix(remove-compare): keep main layer when compare globe is removed (#197
Browse files Browse the repository at this point in the history
)

* feat(url): sync selected layers state to url

* feat(url): sync selected layers state to url

* fix(remove-compare): keep selected main layer when compare globe is removed

* refactor(remove-compare): add conditional path
  • Loading branch information
KatvonRivia authored Nov 15, 2019
1 parent 5125dc2 commit 17e3db1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/scripts/components/remove-compare/remove-compare.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import React, {FunctionComponent} from 'react';
import {useIntl} from 'react-intl';
import {Link} from 'react-router-dom';
import {Link, matchPath, useLocation} from 'react-router-dom';

import {RemoveIcon} from '../icons/remove-icon';

import styles from './remove-compare.styl';

const RemoveCompare: FunctionComponent = () => {
const intl = useIntl();
const location = useLocation();
const match = matchPath(location.pathname, {
path: '(/|/layers)/:mainLayerId?/:compareLayerId?',
exact: true
});

const params = match && match.params;
const mainLayerId = (params && (params as any).mainLayerId) || '';
const newPath = mainLayerId ? `/layers/${mainLayerId}` : '/';

return (
<div className={styles.removeCompare}>
<Link to="/">
<Link to={newPath}>
<button
className={styles.icon}
title={intl.formatMessage({id: 'remove-compare'})}>
Expand Down

0 comments on commit 17e3db1

Please sign in to comment.