add keyboard navigation to course tabs

This commit is contained in:
austinkelsay 2025-04-14 12:11:05 -05:00
parent 660333ffe2
commit a6b442c31d
No known key found for this signature in database
GPG Key ID: 5A763922E5BA08EE

View File

@ -344,6 +344,26 @@ const Course = () => {
return items;
};
// Add keyboard navigation support for tabs
useEffect(() => {
const handleKeyDown = (e) => {
if (e.key === 'ArrowRight') {
const currentIndex = getActiveTabIndex();
const nextIndex = (currentIndex + 1) % getTabItems().length;
toggleTab(nextIndex);
} else if (e.key === 'ArrowLeft') {
const currentIndex = getActiveTabIndex();
const prevIndex = (currentIndex - 1 + getTabItems().length) % getTabItems().length;
toggleTab(prevIndex);
}
};
document.addEventListener('keydown', handleKeyDown);
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [activeTab]);
// Render the QA section (empty for now)
const renderQASection = () => {
return (