From 80e0adcd4969ffda3eb25c8006009a22f1e879f7 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Thu, 30 Oct 2025 23:33:07 +0200 Subject: [PATCH 1/4] fix: removed ability to enter non-number symbols to pagination --- .../src/pages/catalogue/pagination.tsx | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/pages/catalogue/pagination.tsx b/src/renderer/src/pages/catalogue/pagination.tsx index 9febc8f8..8dd85cab 100644 --- a/src/renderer/src/pages/catalogue/pagination.tsx +++ b/src/renderer/src/pages/catalogue/pagination.tsx @@ -29,9 +29,11 @@ function JumpControl({ return isOpen ? ( ) => { - const val = e.target.value; - if (val === "") { + const raw = e.target.value; + const digitsOnly = raw.replace(/\D+/g, ""); + if (digitsOnly === "") { setJumpValue(""); return; } - const num = Number(val); + const num = parseInt(digitsOnly, 10); if (Number.isNaN(num)) { + setJumpValue(""); return; } if (num < 1) { @@ -104,19 +108,38 @@ export function Pagination({ setJumpValue(String(totalPages)); return; } - setJumpValue(val); + setJumpValue(String(num)); }; const onJumpKeyDown = (e: KeyboardEvent) => { + // Allow common control keys + const controlKeys = [ + "Backspace", + "Delete", + "Tab", + "ArrowLeft", + "ArrowRight", + "Home", + "End", + ]; + + if (controlKeys.includes(e.key) || e.ctrlKey || e.metaKey) { + return; + } + if (e.key === "Enter") { - if (jumpValue.trim() === "") return; - const parsed = Number(jumpValue); + const sanitized = jumpValue.replace(/\D+/g, ""); + if (sanitized.trim() === "") return; + const parsed = parseInt(sanitized, 10); if (Number.isNaN(parsed)) return; const target = Math.max(1, Math.min(totalPages, parsed)); onPageChange(target); setIsJumpOpen(false); } else if (e.key === "Escape") { setIsJumpOpen(false); + } else if (!/^\d$/.test(e.key)) { + // Block any non-digit input (e.g., '.', ',') + e.preventDefault(); } }; From bbbf861594575fa8bfa685fecc3dd6e3ca967134 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Thu, 30 Oct 2025 23:36:41 +0200 Subject: [PATCH 2/4] fix: deleted comments --- src/renderer/src/pages/catalogue/pagination.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/renderer/src/pages/catalogue/pagination.tsx b/src/renderer/src/pages/catalogue/pagination.tsx index 8dd85cab..c41635d0 100644 --- a/src/renderer/src/pages/catalogue/pagination.tsx +++ b/src/renderer/src/pages/catalogue/pagination.tsx @@ -112,7 +112,6 @@ export function Pagination({ }; const onJumpKeyDown = (e: KeyboardEvent) => { - // Allow common control keys const controlKeys = [ "Backspace", "Delete", @@ -138,7 +137,6 @@ export function Pagination({ } else if (e.key === "Escape") { setIsJumpOpen(false); } else if (!/^\d$/.test(e.key)) { - // Block any non-digit input (e.g., '.', ',') e.preventDefault(); } }; From bd059cc7fa3800276f053f9650bdd355a85677a9 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Thu, 30 Oct 2025 23:45:29 +0200 Subject: [PATCH 3/4] feat: update cursorrules --- .cursorrules | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cursorrules b/.cursorrules index 0b0c009c..5015ab7e 100644 --- a/.cursorrules +++ b/.cursorrules @@ -27,3 +27,11 @@ - Follow TypeScript strict mode conventions - Use async/await instead of promises when possible - Prefer named exports over default exports for utilities and services + +## Comments + +- Keep comments concise and purposeful; avoid verbose explanations. +- Focus on the "why" or non-obvious context, not restating the code. +- Prefer self-explanatory naming and structure over excessive comments. +- Do not comment every line or obvious behavior; remove stale comments. +- Use docblocks only where they add value (public APIs, complex logic). From aadbda770b5a6479688c40ae6c6f36cc904e06ac Mon Sep 17 00:00:00 2001 From: Moyasee Date: Fri, 31 Oct 2025 00:19:49 +0200 Subject: [PATCH 4/4] fix: linting issue, marked props as read-only --- src/renderer/src/pages/catalogue/pagination.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/pages/catalogue/pagination.tsx b/src/renderer/src/pages/catalogue/pagination.tsx index c41635d0..ecc2afe3 100644 --- a/src/renderer/src/pages/catalogue/pagination.tsx +++ b/src/renderer/src/pages/catalogue/pagination.tsx @@ -58,7 +58,7 @@ export function Pagination({ page, totalPages, onPageChange, -}: PaginationProps) { +}: Readonly) { const { formatNumber } = useFormat(); const [isJumpOpen, setIsJumpOpen] = useState(false); @@ -90,12 +90,12 @@ export function Pagination({ const onJumpChange = (e: ChangeEvent) => { const raw = e.target.value; - const digitsOnly = raw.replace(/\D+/g, ""); + const digitsOnly = raw.replaceAll(/\D+/g, ""); if (digitsOnly === "") { setJumpValue(""); return; } - const num = parseInt(digitsOnly, 10); + const num = Number.parseInt(digitsOnly, 10); if (Number.isNaN(num)) { setJumpValue(""); return; @@ -127,9 +127,9 @@ export function Pagination({ } if (e.key === "Enter") { - const sanitized = jumpValue.replace(/\D+/g, ""); + const sanitized = jumpValue.replaceAll(/\D+/g, ""); if (sanitized.trim() === "") return; - const parsed = parseInt(sanitized, 10); + const parsed = Number.parseInt(sanitized, 10); if (Number.isNaN(parsed)) return; const target = Math.max(1, Math.min(totalPages, parsed)); onPageChange(target);