diff --git a/src/discussions/posts/PostsView.jsx b/src/discussions/posts/PostsView.jsx
index 7cabde43..7c2d3f2b 100644
--- a/src/discussions/posts/PostsView.jsx
+++ b/src/discussions/posts/PostsView.jsx
@@ -52,6 +52,9 @@ function PostsList({ posts, topics }) {
loadThreads(topics);
}
}, [courseId, orderBy, filters, page, JSON.stringify(topics)]);
+
+ const checkIsSelected = (id) => window.location.pathname.includes(id);
+
let lastPinnedIdx = null;
const postInstances = posts && posts.map((post, idx) => {
if (post.pinned && lastPinnedIdx !== false) {
@@ -62,11 +65,11 @@ function PostsList({ posts, topics }) {
return (
-
+
);
}
- return ();
+ return ();
});
return (
<>
diff --git a/src/discussions/posts/post/PostLink.jsx b/src/discussions/posts/post/PostLink.jsx
index 6155ccca..813e92ab 100644
--- a/src/discussions/posts/post/PostLink.jsx
+++ b/src/discussions/posts/post/PostLink.jsx
@@ -1,4 +1,5 @@
import React, { useContext } from 'react';
+import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
@@ -18,6 +19,7 @@ import { postShape } from './proptypes';
function PostLink({
post,
+ isSelected,
intl,
}) {
const {
@@ -40,9 +42,12 @@ function PostLink({
className="discussion-post list-group-item list-group-item-action p-0 text-decoration-none text-gray-900 mw-100"
to={linkUrl}
style={{ lineHeight: '21px', height: '7.5rem' }}
+ aria-current={isSelected(post.id) ? 'page' : undefined}
+ onClick={() => isSelected(post.id)}
>
{post.pinned && (
+ {" "}pinned
)}
@@ -65,6 +70,7 @@ function PostLink({
&& (
{intl.formatMessage(messages.answered)}
+ {" "}answered
)}
@@ -72,6 +78,7 @@ function PostLink({
&& (
{intl.formatMessage(messages.contentReported)}
+ {" "}reported
)}
@@ -82,7 +89,7 @@ function PostLink({
/>
-
+
{isPostPreviewAvailable(post.previewBody)
? post.previewBody
: intl.formatMessage(messages.postWithoutPreview)}
@@ -96,6 +103,7 @@ function PostLink({
PostLink.propTypes = {
post: postShape.isRequired,
+ isSelected: PropTypes.func.isRequired,
intl: intlShape.isRequired,
};
diff --git a/src/discussions/posts/post/PostLink.test.jsx b/src/discussions/posts/post/PostLink.test.jsx
index 05c72fd1..ae324d2e 100644
--- a/src/discussions/posts/post/PostLink.test.jsx
+++ b/src/discussions/posts/post/PostLink.test.jsx
@@ -15,7 +15,7 @@ function renderComponent(post) {
return render(
-
+ true} />
,
);