{
const intl = useIntl();
const { courseId } = useParams();
+ const navigate = useNavigate();
const isSelected = (id) => window.location.pathname.includes(id);
const topicUrl = discussionsPath(Routes.TOPICS.TOPIC, {
courseId,
@@ -26,16 +28,25 @@ const Topic = ({
return (
<>
- isSelected(topic.id)}
+ onClick={() => {
+ isSelected(topic.id);
+ navigate(topicUrl());
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ isSelected(topic.id);
+ navigate(topicUrl());
+ }
+ }}
aria-current={isSelected(topic.id) ? 'page' : undefined}
+ aria-selected={isSelected(topic.id)}
role="option"
tabIndex={(isSelected(topic.id) || index === 0) ? 0 : -1}
+ style={{ cursor: 'pointer' }}
>
-
+
{!showDivider && (
<>
@@ -47,7 +58,7 @@ const Topic = ({