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)
/** Sidebar visible */
const { isOpen } = useSidebar('nc-right-sidebar', { isOpen: true })
const { isOpen } = useSidebar('nc-right-sidebar')
const sidebarCollapsed = computed(() => !isOpen.value)
@ -108,6 +108,7 @@ function onCreate(view: ViewType) {
class="relative shadow-md h-full"
theme="light"
>
{{ isOpen }}
<LazySmartsheetSidebarToolbar
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"

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

@ -45,9 +45,6 @@ const openNewRecordFormHook = createEventHook()
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
provide(MetaInj, meta)
provide(ActiveViewInj, activeView)

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

@ -27,7 +27,10 @@ const createSidebar = (id: string, props: UseSidebarProps = {}) => {
}
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(hasSidebar, storage.hasSidebar)
}
@ -58,7 +61,7 @@ const createSidebar = (id: string, props: UseSidebarProps = {}) => {
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 = {}) => {
const sidebar = id.includes('left') ? leftSidebar() : rightSidebar()

Loading…
Cancel
Save