Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(pdf-viewer): resolve empty outline panel issue (#911)

Corentin Thomasset548608be39bd
diff --git a/.changeset/swift-wolves-enjoy.md b/.changeset/swift-wolves-enjoy.md
new file mode 100644
index 00000000..002d8cc9
--- /dev/null
+++ b/.changeset/swift-wolves-enjoy.md
@@ -0,0 +1,5 @@
+---
+"@papra/app": patch
+---
+
+In the advanced PDF viewer, added empty placeholders for thumbnails to prevent layout shifts.
diff --git a/.changeset/warm-flies-love.md b/.changeset/warm-flies-love.md
new file mode 100644
index 00000000..65c09aa6
--- /dev/null
+++ b/.changeset/warm-flies-love.md
@@ -0,0 +1,5 @@
+---
+"@papra/app": patch
+---
+
+Fix an issue in the advanced PDF that caused the outline panel to appear empty
\ No newline at end of file
diff --git a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/attachments-panel.component.tsx b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/attachments-panel.component.tsx
index b03e026e..272d41e4 100644
--- a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/attachments-panel.component.tsx
+++ b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/attachments-panel.component.tsx
@@ -1,16 +1,14 @@
import type { Component } from 'solid-js';
import type { PDFSlickState } from '../pdf-viewer.types';
import { For } from 'solid-js';
-import { cn } from '@/modules/shared/style/cn';
type AttachmentsPanelProps = {
store: PDFSlickState;
- show: boolean;
};
export const AttachmentsPanel: Component<AttachmentsPanelProps> = (props) => {
return (
- <div class={cn('p-2 text-sm', { invisible: !props.show })}>
+ <div class="p-2 text-sm">
<For each={Array.from(props.store.attachments.values())}>
{({ filename, content }) => (
<button
diff --git a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/outline-panel.component.tsx b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/outline-panel.component.tsx
index 4a3b3d29..e9aa5a90 100644
--- a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/outline-panel.component.tsx
+++ b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/outline-panel.component.tsx
@@ -6,7 +6,6 @@ import { Button } from '@/modules/ui/components/button';
type OutlinePanelProps = {
store: PDFSlickState;
- show: boolean;
};
const OutlineItem: Component<{ title: string; dest: any; items?: TPDFDocumentOutline; store: PDFSlickState; level: number }> = (props) => {
@@ -73,7 +72,7 @@ const OutlineItems: Component<{
export const OutlinePanel: Component<OutlinePanelProps> = (props) => {
return (
- <div class={cn('overflow-auto pt-2 text-foreground text-sm', { invisible: !props.show })}>
+ <div class="pt-2 text-foreground text-sm">
<OutlineItems
outline={props.store.documentOutline}
store={props.store}
diff --git a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/sidebar.component.tsx b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/sidebar.component.tsx
index a9801ebc..e14b5758 100644
--- a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/sidebar.component.tsx
+++ b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/sidebar.component.tsx
@@ -1,11 +1,23 @@
-import type { Component } from 'solid-js';
+import type { Component, ParentComponent } from 'solid-js';
import type { ThumbnailsBarProps, ThumbnailsBarTab } from '../pdf-viewer.types';
import { createSignal } from 'solid-js';
+import { cn } from '@/modules/shared/style/cn';
import { AttachmentsPanel } from './attachments-panel.component';
import { OutlinePanel } from './outline-panel.component';
import { SidebarButtonsBar } from './sidebar-buttons-bar.component';
import { ThumbnailsPanel } from './thumbnails-panel.component';
+const SideBarPanel: ParentComponent<{ active: boolean }> = (props) => {
+ return (
+ <div
+ class={cn('absolute inset-0 flex flex-col overflow-y-auto transition-opacity z-10', { 'opacity-0 pointer-events-none z-0': !props.active })}
+ aria-hidden={!props.active}
+ >
+ {props.children}
+ </div>
+ );
+};
+
export const SideBar: Component<ThumbnailsBarProps> = (props) => {
const [activeTab, setActiveTab] = createSignal<ThumbnailsBarTab>('thumbnails');
@@ -17,20 +29,20 @@ export const SideBar: Component<ThumbnailsBarProps> = (props) => {
setActiveTab={setActiveTab}
/>
- <div class="flex-1 relative transition-all duration-200">
- <ThumbnailsPanel
- show={activeTab() === 'thumbnails'}
- store={props.store}
- thumbsRef={props.thumbsRef}
- />
- <OutlinePanel
- show={activeTab() === 'outline'}
- store={props.store}
- />
- <AttachmentsPanel
- show={activeTab() === 'attachments'}
- store={props.store}
- />
+ <div class="flex-1 relative overflow-hidden min-h-0">
+
+ <SideBarPanel active={activeTab() === 'thumbnails'}>
+ <ThumbnailsPanel store={props.store} thumbsRef={props.thumbsRef} />
+ </SideBarPanel>
+
+ <SideBarPanel active={activeTab() === 'outline'}>
+ <OutlinePanel store={props.store} />
+ </SideBarPanel>
+
+ <SideBarPanel active={activeTab() === 'attachments'}>
+ <AttachmentsPanel store={props.store} />
+ </SideBarPanel>
+
</div>
</div>
);
diff --git a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/thumbnails-panel.component.tsx b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/thumbnails-panel.component.tsx
index cd24c937..c0ff3ec1 100644
--- a/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/thumbnails-panel.component.tsx
+++ b/apps/papra-client/src/modules/documents/components/pdf-viewer/sidebar/thumbnails-panel.component.tsx
@@ -8,7 +8,6 @@ import { cn } from '@/modules/shared/style/cn';
type ThumbnailsPanelProps = {
store: PDFSlickState;
thumbsRef: (instance: HTMLElement) => void;
- show: boolean;
};
const PageThumbnail: Component<{
@@ -17,7 +16,6 @@ const PageThumbnail: Component<{
src: string | null;
width: number;
height: number;
- loaded: boolean;
onClick?: () => void;
currentPage: number;
altText: string;
@@ -30,15 +28,18 @@ const PageThumbnail: Component<{
onClick={props.onClick}
class={cn('p-2 rounded-xl transition-colors hover:bg-accent mx-auto block', { 'bg-muted': isCurrentPageSelected() })}
>
- {props.src && (
- <img
- src={props.src}
- width={props.width}
- height={props.height}
- alt={props.altText}
- class="block rounded"
- />
- )}
+ <div
+ class="rounded bg-muted overflow-hidden"
+ style={{ width: `${props.width}px`, height: `${props.height}px` }}
+ >
+ {props.src && (
+ <img
+ src={props.src}
+ alt={props.altText}
+ class="block w-full h-full"
+ />
+ )}
+ </div>
<div
class={cn('text-center text-xs pt-2 transition-colors text-muted-foreground', { 'text-foreground font-medium': isCurrentPageSelected() })}
@@ -71,7 +72,7 @@ export const ThumbnailsPanel: Component<ThumbnailsPanelProps> = (props) => {
return (
<div
- class={cn('px-2 relative h-full', { invisible: !props.show })}
+ class="px-2 relative h-full"
ref={containerRef}
>
<PDFSlickThumbnails
@@ -87,14 +88,13 @@ export const ThumbnailsPanel: Component<ThumbnailsPanelProps> = (props) => {
},
)}
>
- {({ pageNumber, width, height, src, pageLabel, loaded }) => (
+ {({ pageNumber, width, height, src, pageLabel }) => (
<PageThumbnail
pageNumber={pageNumber}
width={width}
height={height}
src={src}
pageLabel={pageLabel}
- loaded={loaded}
currentPage={props.store.pageNumber}
onClick={() => props.store.pdfSlick?.gotoPage(pageNumber)}
altText={t('documents.pdf-viewer.thumbnails.page-alt', { page: pageLabel ?? pageNumber })}