Skip to content

Commit 29eb3f2

Browse files
committed
Simplify buttons to match tabs
1 parent 6661724 commit 29eb3f2

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

packages/react/src/table/table.tsx

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@ function Table(props: TableProps) {
101101
});
102102
}, []);
103103

104-
const handleKeyDown = useCallback(
105-
(event: React.KeyboardEvent, direction: 'left' | 'right') => {
106-
// Support Enter and Space for activation (WCAG 2.1.1)
107-
if (event.key === 'Enter' || event.key === ' ') {
108-
event.preventDefault();
109-
handleScroll(direction);
110-
}
111-
},
112-
[handleScroll],
113-
);
114-
115104
const scrollHandler = useDebouncedCallback(checkScrollOverflow, 100);
116105

117106
useEffect(() => {
@@ -144,17 +133,15 @@ function Table(props: TableProps) {
144133
{scrollPosition === 'end' && 'Tabell ved slutt'}
145134
</div>
146135

147-
<NavigationButton
136+
<ScrollButton
148137
direction="left"
149138
onClick={() => handleScroll('left')}
150-
onKeyDown={(e) => handleKeyDown(e, 'left')}
151139
canScroll={canScrollLeft}
152140
/>
153141

154-
<NavigationButton
142+
<ScrollButton
155143
direction="right"
156144
onClick={() => handleScroll('right')}
157-
onKeyDown={(e) => handleKeyDown(e, 'right')}
158145
canScroll={canScrollRight}
159146
/>
160147

@@ -174,52 +161,40 @@ function Table(props: TableProps) {
174161
}
175162

176163
/**
177-
* Navigation button component for table scrolling
178-
* Supports keyboard interaction and proper WCAG compliance
164+
* Scroll button component for table horizontal scrolling
165+
* Simple div-based button for mouse interaction only
179166
*/
180-
interface NavigationButtonProps {
167+
interface ScrollButtonProps {
181168
direction: 'left' | 'right';
182169
onClick: () => void;
183-
onKeyDown: (event: React.KeyboardEvent) => void;
184170
canScroll: boolean;
185171
}
186172

187-
function NavigationButton({
188-
direction,
189-
onClick,
190-
onKeyDown,
191-
canScroll,
192-
}: NavigationButtonProps) {
173+
function ScrollButton({ direction, onClick, canScroll }: ScrollButtonProps) {
193174
const Icon = direction === 'left' ? ChevronLeft : ChevronRight;
194175
const position = direction === 'left' ? 'left-0' : 'right-0';
195-
const ariaLabel = `Scroll tabell ${direction === 'left' ? 'til venstre' : 'til høyre'}`;
196176
const bg =
197177
direction === 'left'
198178
? 'bg-[linear-gradient(90deg,white,white_calc(100%-10px),transparent)]'
199179
: 'bg-[linear-gradient(90deg,transparent,white_calc(10px),white)]';
200180

201181
return (
202-
<button
203-
type="button"
182+
// biome-ignore lint/a11y/useKeyWithClickEvents: This button is only for mouse interaction to help users scroll. Keyboard and screen reader users can navigate the table content directly without needing these scroll helpers.
183+
<div
204184
onClick={onClick}
205-
onKeyDown={onKeyDown}
206185
className={cx(
207186
'-translate-y-1/2 absolute top-5 z-10',
208187
position,
209188
'flex h-11 w-11 items-center justify-center',
210189
'cursor-pointer text-black transition-all duration-150 ease-out',
211190
bg,
212191
'hover:bg-white',
213-
'data-focus-visible:outline-focus-offset',
214192
'motion-safe:transition-all motion-reduce:transition-none',
215193
canScroll ? 'visible opacity-100' : 'invisible opacity-0',
216194
)}
217-
aria-label={ariaLabel}
218-
aria-hidden={!canScroll}
219-
tabIndex={canScroll ? 0 : -1}
220195
>
221-
<Icon className="h-5 w-5" aria-hidden="true" />
222-
</button>
196+
<Icon className="h-5 w-5" />
197+
</div>
223198
);
224199
}
225200

0 commit comments

Comments
 (0)