Skip to content

Commit

Permalink
fix: clicking nav closes the sidebar
Browse files Browse the repository at this point in the history
closes #601
  • Loading branch information
wojtek-krysiak committed Sep 26, 2020
1 parent cea767f commit ffc92a6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/frontend/components/application.tsx
@@ -1,9 +1,10 @@
/* eslint-disable react/no-children-prop */
import React from 'react'
import React, { useEffect, useState } from 'react'
import { Switch, Route } from 'react-router-dom'
import { createGlobalStyle } from 'styled-components'
import { Box, Overlay, Reset } from '@admin-bro/design-system'

import { useLocation } from 'react-router'
import ViewHelpers from '../../backend/utils/view-helpers/view-helpers'
import Sidebar from './app/sidebar/sidebar'
import TopBar from './app/top-bar'
Expand All @@ -12,7 +13,6 @@ import Notice from './app/notice'
import {
Dashboard, ResourceAction, RecordAction, Page, BulkAction, Resource,
} from './routes'
import { useLocalStorage } from '../hooks'

const GlobalStyle = createGlobalStyle`
html, body, #app {
Expand All @@ -24,9 +24,15 @@ const GlobalStyle = createGlobalStyle`
}
`

const h = new ViewHelpers()

const App: React.FC = () => {
const [sidebarVisible, toggleSidebar] = useLocalStorage('sidebarVisible', false)
const h = new ViewHelpers()
const [sidebarVisible, toggleSidebar] = useState(false)
const location = useLocation()

useEffect(() => {
if (sidebarVisible) { toggleSidebar(false) }
}, [location])

const resourceId = ':resourceId'
const actionName = ':actionName'
Expand Down

0 comments on commit ffc92a6

Please sign in to comment.