Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions apps/web/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* Fix: change the import to `useDebounce`.
*/

// BUG: useThrottle no longer exists — was renamed to useDebounce
import { useThrottle } from "@e2e/utils"
import { useDebounce } from "@e2e/utils"
import { formatDate, formatAUD } from "@e2e/utils"

export const BASE_URL = process.env.API_URL ?? "http://localhost:3000"
Expand All @@ -28,5 +27,4 @@ export async function fetchPosts() {
// Re-export formatting utilities used throughout the app
export { formatDate, formatAUD }

// Re-export the debounce hook (currently broken import)
export { useThrottle as useSearchDebounce }
export { useDebounce as useSearchDebounce }
18 changes: 5 additions & 13 deletions packages/ui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@ type Props = {
onClick?: () => void
/** Accessible label — REQUIRED when iconOnly is true */
"aria-label"?: string
/** Tooltip / accessible name fallback when aria-label is omitted */
title?: string
}

/**
* Button component.
*
* BUG: When `iconOnly` is true, the button renders without visible text.
* An `aria-label` is required for screen reader accessibility (WCAG 2.1 SC 4.1.2),
* but the component does not enforce or warn about its absence.
*
* The test in Button.test.tsx checks that an icon-only button has an accessible name.
* Fix: throw/warn in development when `iconOnly && !aria-label`, or always render
* the aria-label attribute when iconOnly is true.
*/
export function Button({
children,
icon,
Expand All @@ -33,14 +24,15 @@ export function Button({
disabled = false,
onClick,
"aria-label": ariaLabel,
title,
}: Props) {
return (
<button
className={`btn btn-${variant}`}
disabled={disabled}
onClick={onClick}
// BUG: aria-label is not applied when iconOnly is true and no ariaLabel is passed
// The component should enforce aria-label for icon-only buttons
title={title}
aria-label={ariaLabel ?? title ?? (iconOnly ? "button" : undefined)}
>
{icon && <span className="btn-icon">{icon}</span>}
{!iconOnly && children}
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ export function DataTable<T extends Record<string, unknown>>({ data, columns }:
const [sortKey, setSortKey] = useState<keyof T | null>(null)
const [sortDir, setSortDir] = useState<SortDir>("asc")

// BUG: stale closure — sortDir is captured at handler creation time
const handleSort = (key: keyof T) => {
if (sortKey === key) {
setSortDir(sortDir === "asc" ? "desc" : "asc") // BUG: reads stale sortDir
setSortDir(prev => prev === "asc" ? "desc" : "asc")
} else {
setSortKey(key)
setSortDir("asc")
Expand Down
5 changes: 1 addition & 4 deletions packages/utils/src/format/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
* and rely on the locale to order them correctly.
*/
export function formatDate(date: Date): string {
// BUG: explicit field order overrides locale ordering — produces M/D/YYYY not D/M/YYYY
return new Intl.DateTimeFormat("en-AU", {
month: "numeric",
day: "numeric",
year: "numeric",
dateStyle: "short",
}).format(date)
}

Expand Down