Skip to content

Commit

Permalink
Fix: Do not refresh the page after navigating back from isolated / fo…
Browse files Browse the repository at this point in the history
…cus mode (styleguidist#617)
  • Loading branch information
BTMPL authored and sapegin committed Oct 4, 2017
1 parent 0f06fcc commit 09d2452
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ function renderStyleguide() {
}
document.title = documentTitle;

// If the current hash location was set to just `/` (e.g. when navigating back from isolated view to overview)
// replace the URL with one without hash, to present the user with a single address of the overview screen
const hash = location.hash.slice(1);
if (hash === '/') {
const url = window.location.pathname + window.location.search;
history.replaceState('', document.title, url);
}

ReactDOM.render(
<StyleGuide
codeRevision={codeRevision}
Expand Down
2 changes: 1 addition & 1 deletion src/rsg-components/slots/IsolateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getUrl } from '../../utils/utils';

const IsolateButton = ({ name, example, isolated }) =>
isolated ? (
<ToolbarButton href={getUrl()} title="Show all components">
<ToolbarButton href={getUrl({ anchor: true, slug: '/' })} title="Show all components">
<MdFullscreenExit />
</ToolbarButton>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`should renderer a link home in isolated mode 1`] = `
<Styled(ToolbarButton)
href="blank"
href="blank#/"
title="Show all components"
>
<MdFullscreenExit />
Expand Down

0 comments on commit 09d2452

Please sign in to comment.