Change links in multi-column mode so tabs are open in single-column mode (#25893)
This commit is contained in:
parent
41f65edb21
commit
5fad7bd58a
12 changed files with 77 additions and 19 deletions
|
@ -11,13 +11,21 @@ import BundleContainer from '../containers/bundle_container';
|
|||
|
||||
// Small wrapper to pass multiColumn to the route components
|
||||
export class WrappedSwitch extends PureComponent {
|
||||
static contextTypes = {
|
||||
router: PropTypes.object,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { multiColumn, children } = this.props;
|
||||
const { location } = this.context.router.route;
|
||||
|
||||
const decklessLocation = multiColumn && location.pathname.startsWith('/deck')
|
||||
? {...location, pathname: location.pathname.slice(5)}
|
||||
: location;
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
{Children.map(children, child => cloneElement(child, { multiColumn }))}
|
||||
<Switch location={decklessLocation}>
|
||||
{Children.map(children, child => child ? cloneElement(child, { multiColumn }) : null)}
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue