Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOP-873: Fix sidebar/left navtab on-load flashing #169

Merged
merged 3 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/styles/navigation.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.left-column {
.leftColumn.postRender {
display: flex !important;
}

.showNav {
.showNav.postRender {
display: block !important;
}
}

11 changes: 7 additions & 4 deletions src/templates/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Helmet } from 'react-helmet';
import { getPlaintextTitle } from '../utils/get-plaintext-title.js';
import { useWindowSize } from '../hooks/use-window-size.js';
import style from '../styles/navigation.module.css';
import { isBrowser } from '../utils/is-browser.js';

const Document = props => {
const {
Expand All @@ -28,6 +29,8 @@ const Document = props => {
const minWindowWidth = 1093; /* Specific value from docs-tools/themes/mongodb/src/css/mongodb-base.css */

const [showLeftColumn, setShowLeftColumn] = useState(windowSize.width > minWindowWidth);
/* Add the postRender CSS class without disturbing pre-render functionality */
const renderStatus = isBrowser() ? style.postRender : '';

const toggleLeftColumn = () => {
setShowLeftColumn(!showLeftColumn);
Expand All @@ -41,8 +44,8 @@ const Document = props => {
<Navbar />
<div className="content">
<div>
{showLeftColumn && (
<div className={`left-column ${style.leftColumn}`} id="left-column">
{(!isBrowser() || showLeftColumn) && (
<div className={`left-column ${style.leftColumn} ${renderStatus}`} id="left-column">
<Sidebar
slug={slug}
publishedBranches={publishedBranches}
Expand All @@ -53,8 +56,8 @@ const Document = props => {
)}
</div>
<div className="main-column" id="main-column">
{!showLeftColumn && (
<span className={`showNav ${style.showNav}`} id="showNav" onClick={toggleLeftColumn}>
{(!isBrowser() || !showLeftColumn) && (
<span className={`showNav ${style.showNav} ${renderStatus}`} id="showNav" onClick={toggleLeftColumn}>
Navigation
</span>
)}
Expand Down