fix(stock-orders): keyboard a11y on pagination + soft row nav
- Disabled pagination links (Previous at page 1, Next at last page) now also set tabIndex=-1 and preventDefault on click, so keyboard users can't activate them when at the boundary. aria-disabled + pointer-events-none blocked only mouse clicks. - Row click uses useRouter().push() instead of window.location.href for a soft navigation that preserves client state (consistent with the original /stock-orders page). Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
0c556a0513
commit
fcb15a20e2
1 changed files with 12 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -105,6 +106,8 @@ export default function StockOrdersTable({
|
|||
const [quickDraftOpen, setQuickDraftOpen] = useState(false);
|
||||
const [editingPurchaseId, setEditingPurchaseId] = useState<string | null>(null);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const openEditForDraft = (purchaseId: string) => {
|
||||
setEditingPurchaseId(purchaseId);
|
||||
setQuickDraftOpen(true);
|
||||
|
|
@ -200,7 +203,7 @@ export default function StockOrdersTable({
|
|||
key={row.id}
|
||||
className="cursor-pointer"
|
||||
onClick={() => {
|
||||
window.location.href = `/stock-orders/${row.id}`;
|
||||
router.push(`/stock-orders/${row.id}`);
|
||||
}}
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
|
|
@ -266,6 +269,10 @@ export default function StockOrdersTable({
|
|||
<Link
|
||||
href={pageHref(page - 1)}
|
||||
aria-disabled={page <= 1}
|
||||
tabIndex={page <= 1 ? -1 : undefined}
|
||||
onClick={(e) => {
|
||||
if (page <= 1) e.preventDefault();
|
||||
}}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline", size: "sm" }),
|
||||
page <= 1 && "pointer-events-none opacity-50",
|
||||
|
|
@ -279,6 +286,10 @@ export default function StockOrdersTable({
|
|||
<Link
|
||||
href={pageHref(page + 1)}
|
||||
aria-disabled={page >= totalPages}
|
||||
tabIndex={page >= totalPages ? -1 : undefined}
|
||||
onClick={(e) => {
|
||||
if (page >= totalPages) e.preventDefault();
|
||||
}}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline", size: "sm" }),
|
||||
page >= totalPages && "pointer-events-none opacity-50",
|
||||
|
|
|
|||
Loading…
Reference in a new issue