Fix: prevent pdfjs highlight scrolling from affecting the entire page (#13355)

This commit is contained in:
shamoon
2026-07-27 17:25:52 -07:00
committed by GitHub
parent dcff067dc1
commit 0b588c2d31
3 changed files with 12 additions and 1 deletions
@@ -1,6 +1,7 @@
<a [href]="link ?? previewUrl" class="{{linkClasses}}" [target]="linkTarget" [title]="linkTitle"
[ngbPopover]="previewContent" [popoverTitle]="document.title | documentTitle" container="body"
autoClose="true" [popoverClass]="popoverClass()" (mouseenter)="mouseEnterPreview()" (mouseleave)="mouseLeavePreview()" #popover="ngbPopover">
autoClose="true" [popoverClass]="popoverClass()" [popperOptions]="popperOptions"
(mouseenter)="mouseEnterPreview()" (mouseleave)="mouseLeavePreview()" #popover="ngbPopover">
<ng-content></ng-content>
</a>
<ng-template #previewContent>
@@ -67,6 +67,10 @@ describe('PreviewPopupComponent', () => {
expect(component.useNativePdfViewer).toBeTruthy()
})
it('should use fixed positioning for the preview popover', () => {
expect(component.popperOptions({}).strategy).toEqual('fixed')
})
it('should render object if native PDF viewer enabled', () => {
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, true)
component.popover.open()
@@ -8,6 +8,7 @@ import {
ViewChild,
} from '@angular/core'
import { NgbPopover, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'
import { Options } from '@popperjs/core'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { first, Subject, takeUntil } from 'rxjs'
import { Document } from 'src/app/data/document'
@@ -74,6 +75,11 @@ export class PreviewPopupComponent implements OnDestroy {
readonly popoverClass = signal('shadow popover-preview')
readonly popperOptions = (options: Partial<Options>): Partial<Options> => ({
...options,
strategy: 'fixed',
})
get renderAsObject(): boolean {
return (this.isPdf && this.useNativePdfViewer) || !this.isPdf
}