Browse Source

fix(nc-gui): right sidebar state not restored

pull/3801/head
braks 2 years ago
parent
commit
2f925e008f
  1. 3
      packages/nc-gui/components/smartsheet/sidebar/index.vue
  2. 3
      packages/nc-gui/components/tabs/Smartsheet.vue
  3. 7
      packages/nc-gui/composables/useSidebar/index.ts

3
packages/nc-gui/components/smartsheet/sidebar/index.vue

@ -34,7 +34,7 @@ const { $e } = useNuxtApp()
provide(ViewListInj, views) provide(ViewListInj, views)
/** Sidebar visible */ /** Sidebar visible */
const { isOpen } = useSidebar('nc-right-sidebar', { isOpen: true }) const { isOpen } = useSidebar('nc-right-sidebar')
const sidebarCollapsed = computed(() => !isOpen.value) const sidebarCollapsed = computed(() => !isOpen.value)
@ -108,6 +108,7 @@ function onCreate(view: ViewType) {
class="relative shadow-md h-full" class="relative shadow-md h-full"
theme="light" theme="light"
> >
{{ isOpen }}
<LazySmartsheetSidebarToolbar <LazySmartsheetSidebarToolbar
v-if="isOpen" v-if="isOpen"
class="min-h-[var(--toolbar-height)] max-h-[var(--toolbar-height)] flex items-center py-3 px-3 justify-between border-b-1" class="min-h-[var(--toolbar-height)] max-h-[var(--toolbar-height)] flex items-center py-3 px-3 justify-between border-b-1"

3
packages/nc-gui/components/tabs/Smartsheet.vue

@ -45,9 +45,6 @@ const openNewRecordFormHook = createEventHook()
const { isGallery, isGrid, isForm, isLocked } = useProvideSmartsheetStore(activeView, meta) const { isGallery, isGrid, isForm, isLocked } = useProvideSmartsheetStore(activeView, meta)
// provide the sidebar injection state
useSidebar('nc-right-sidebar', { useStorage: true, isOpen: true })
// todo: move to store // todo: move to store
provide(MetaInj, meta) provide(MetaInj, meta)
provide(ActiveViewInj, activeView) provide(ActiveViewInj, activeView)

7
packages/nc-gui/composables/useSidebar/index.ts

@ -27,7 +27,10 @@ const createSidebar = (id: string, props: UseSidebarProps = {}) => {
} }
if (props.useStorage) { if (props.useStorage) {
const storage = toRefs(useStorage(id, { isOpen, hasSidebar }, localStorage, { mergeDefaults: true }).value) const storage = toRefs(useStorage(id, { isOpen, hasSidebar }, localStorage).value)
isOpen.value = storage.isOpen.value
hasSidebar.value = storage.hasSidebar.value
syncRef(isOpen, storage.isOpen) syncRef(isOpen, storage.isOpen)
syncRef(hasSidebar, storage.hasSidebar) syncRef(hasSidebar, storage.hasSidebar)
} }
@ -58,7 +61,7 @@ const createSidebar = (id: string, props: UseSidebarProps = {}) => {
const leftSidebar = createSharedComposable(() => createSidebar('leftSidebar')) const leftSidebar = createSharedComposable(() => createSidebar('leftSidebar'))
const rightSidebar = createSharedComposable(() => createSidebar('rightSidebar', { useStorage: true })) const rightSidebar = createSharedComposable(() => createSidebar('rightSidebar', { useStorage: true, isOpen: true }))
export const useSidebar = (id: string, props: UseSidebarProps = {}) => { export const useSidebar = (id: string, props: UseSidebarProps = {}) => {
const sidebar = id.includes('left') ? leftSidebar() : rightSidebar() const sidebar = id.includes('left') ? leftSidebar() : rightSidebar()

Loading…
Cancel
Save