Merge pull request #919 from kelseyjmw/fix-crop-scroll

Fix crop scroll
This commit is contained in:
Alam
2026-10-31 16:38:58 +05:30
committed by GitHub
2 changed files with 21 additions and 1 deletions
+3 -1
View File
@@ -424,7 +424,7 @@ async function performFlatteningCrop(
return newPdfDoc.save();
}
function resetState() {
export function resetState() {
if (cropperState.cropper) {
cropperState.cropper.destroy();
cropperState.cropper = null;
@@ -447,4 +447,6 @@ function resetState() {
const cropBtn = document.getElementById('crop-button') as HTMLButtonElement;
if (cropBtn) cropBtn.disabled = true;
window.scrollTo({ top: 0, behavior: 'smooth' });
}
+18
View File
@@ -0,0 +1,18 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { resetState } from '../js/logic/crop-pdf-page.ts';
// Test resetState function for cropping
describe('resetState', () => {
beforeEach(() => {
vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
});
it('scrolls the page to the top after resetting', () => {
resetState();
expect(window.scrollTo).toHaveBeenCalledWith({
top: 0,
behavior: 'smooth',
});
});
});