diff --git a/dotcom-rendering/src/components/Discussion.tsx b/dotcom-rendering/src/components/Discussion.tsx index 2ffe37ef8f2..5cab7ca56ff 100644 --- a/dotcom-rendering/src/components/Discussion.tsx +++ b/dotcom-rendering/src/components/Discussion.tsx @@ -173,6 +173,12 @@ export const Discussion = ({ } }, [discussionApiUrl, hashCommentId]); + useEffect(() => { + if (window.location.hash === '#comments') { + setIsExpanded(true); + } + }, []); + useEffect(() => { // There's no point showing the view more button if there isn't much more to view if (commentCount === 0 || commentCount === 1 || commentCount === 2) { diff --git a/dotcom-rendering/src/components/Discussion/Comments.stories.tsx b/dotcom-rendering/src/components/Discussion/Comments.stories.tsx index 0c227d324f7..224330e1341 100644 --- a/dotcom-rendering/src/components/Discussion/Comments.stories.tsx +++ b/dotcom-rendering/src/components/Discussion/Comments.stories.tsx @@ -4,13 +4,12 @@ import { splitTheme } from '../../../.storybook/decorators/splitThemeDecorator'; import { lightDecorator } from '../../../.storybook/decorators/themeDecorator'; import { discussion as discussionMock } from '../../../fixtures/manual/discussion'; import { discussionWithTwoComments } from '../../../fixtures/manual/discussionWithTwoComments'; +import { legacyDiscussionWithoutThreading } from '../../../fixtures/manual/legacyDiscussionWithoutThreading'; import type { FilterOptions, SignedInUser } from '../../types/discussion'; import { Comments } from './Comments'; export default { component: Comments, title: 'Discussion/App' }; -const { discussion, pages } = discussionMock; - const aUser: SignedInUser = { profile: { userId: 'abc123', @@ -49,7 +48,7 @@ export const LoggedOutHiddenPicks = () => ( `} > ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={discussionMock.discussion.commentCount} loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={discussionMock.pages} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -91,7 +90,7 @@ export const InitialPage = () => ( `} > ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={discussionMock.discussion.commentCount} loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={discussionMock.pages} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -150,10 +149,10 @@ export const LoggedInHiddenNoPicks = () => ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={discussionMock.discussion.commentCount} loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={discussionMock.pages} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -187,10 +186,10 @@ export const LoggedIn = () => ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={discussionMock.discussion.commentCount} loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={discussionMock.pages} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -258,10 +257,10 @@ export const LoggedOutHiddenNoPicks = () => ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={0} + commentCount={discussionMock.discussion.commentCount} loading={false} totalPages={0} - comments={[]} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -285,7 +284,7 @@ export const Closed = () => ( `} > ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={discussionMock.discussion.commentCount} loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={discussionMock.pages} + comments={discussionMock.discussion.comments} setComments={() => {}} /> @@ -370,7 +369,7 @@ export const LegacyDiscussion = () => ( `} > ( setPage={() => {}} filters={filters} setFilters={() => {}} - commentCount={discussion.commentCount} + commentCount={ + legacyDiscussionWithoutThreading.discussion.commentCount + } loading={false} - totalPages={pages} - comments={discussion.comments} + totalPages={legacyDiscussionWithoutThreading.pages} + comments={legacyDiscussionWithoutThreading.discussion.comments} setComments={() => {}} />