Skip to content

Commit 3d72fa0

Browse files
committed
Lint fixes
1 parent 57e4dca commit 3d72fa0

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/components/NotificationPopup/NotificationPopup.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type HTMLAttributes, type ReactNode, type Ref, useEffect, useRef, useCallback, useState } from 'react';
2+
23
import { CloseButton } from '../CloseButton';
34
import { ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '../../icons';
45
import type { NotificationPopupLabels } from '../../labels';
@@ -82,18 +83,18 @@ export function NotificationPopup({
8283

8384
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
8485
const pausedRef = useRef(false);
85-
const prevVisibleRef = useRef(visible);
8686

8787
const [paused, setPaused] = useState(false);
8888
const [mounted, setMounted] = useState(visible);
8989
const [leaving, setLeaving] = useState(false);
9090
const [progressKey, setProgressKey] = useState(0);
91+
const [prevVisible, setPrevVisible] = useState(visible);
9192

9293
// Derive mount/leave state from the `visible` prop during render.
9394
// Calling setState here uses React's "update during render" pattern: React immediately
9495
// discards the current output and retries — no cascading renders, no effect involvement.
95-
if (prevVisibleRef.current !== visible) {
96-
prevVisibleRef.current = visible;
96+
if (prevVisible !== visible) {
97+
setPrevVisible(visible);
9798
if (visible) {
9899
if (!mounted) setMounted(true);
99100
if (leaving) setLeaving(false);

src/components/Table/Table.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
149149
onRowClick,
150150
className,
151151
ref,
152-
onKeyDown,
153152
labels,
154153
...rest
155154
}: TableProps<T>) {
156155
const ctx = useComponentLibraryStrings();
157-
const l = { ...DEFAULT_TABLE_LABELS, ...ctx.table, ...labels };
156+
const l = useMemo(
157+
() => ({ ...DEFAULT_TABLE_LABELS, ...ctx.table, ...labels }),
158+
[ctx.table, labels],
159+
);
158160

159161
const [sortKey, setSortKey] = useState<string | null>(null);
160162
const [sortDir, setSortDir] = useState<SortDirection>('none');
@@ -220,7 +222,7 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
220222
setAnnouncement('');
221223
}
222224
},
223-
[data, columns],
225+
[data, columns, l],
224226
);
225227

226228
/* Row interaction — selection toggle + optional onRowClick callback */
@@ -235,7 +237,7 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
235237
}
236238
onRowClick?.(row, globalIdx);
237239
},
238-
[selectable, onRowClick],
240+
[selectable, onRowClick, l.rowSelected, l.selectionCleared],
239241
);
240242

241243
const handleRowKeyDown = useCallback(
@@ -248,16 +250,15 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
248250
[handleRowInteraction],
249251
);
250252

251-
/* Escape on the wrapper clears row selection */
252-
const handleWrapperKeyDown = useCallback(
253-
(e: KeyboardEvent<HTMLDivElement>) => {
253+
/* Escape on the table clears row selection */
254+
const handleTableKeyDown = useCallback(
255+
(e: KeyboardEvent<HTMLTableElement>) => {
254256
if (e.key === 'Escape' && selectedRow !== null) {
255257
setSelectedRow(null);
256258
setAnnouncement(l.selectionCleared);
257259
}
258-
onKeyDown?.(e);
259260
},
260-
[selectedRow, onKeyDown],
261+
[selectedRow, l.selectionCleared],
261262
);
262263

263264
/* Resize handler */
@@ -298,8 +299,12 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
298299
...(headerTextColor ? { '--table-header-color': headerTextColor } : {}),
299300
} as CSSProperties;
300301

302+
const tableInteractionProps = selectable
303+
? { role: 'grid' as const, onKeyDown: handleTableKeyDown }
304+
: {};
305+
301306
return (
302-
<div ref={ref} className={classNames} onKeyDown={handleWrapperKeyDown} {...rest}>
307+
<div ref={ref} className={classNames} {...rest}>
303308
{/* Screen reader live region for search results and selection state */}
304309
<div
305310
id={liveRegionId}
@@ -340,7 +345,7 @@ export function Table<T extends Record<string, unknown> = Record<string, unknown
340345
.join(' ')}
341346
style={tableStyle}
342347
aria-busy={loading || undefined}
343-
role={selectable ? 'grid' : undefined}
348+
{...tableInteractionProps}
344349
>
345350
{caption && <caption className={styles.caption}>{caption}</caption>}
346351
<thead className={styles.thead}>

0 commit comments

Comments
 (0)