-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wsteama 1417 add related content link to jump to component #12157
base: latest
Are you sure you want to change the base?
Wsteama 1417 add related content link to jump to component #12157
Conversation
src/app/components/JumpTo/index.tsx
Outdated
const idWithHash = `#${sanitisedId}`; | ||
const idWithHash = | ||
sanitisedId === 'Related-Content' | ||
? '#related-content-heading' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#related-content-heading
looks to be on the span
, not the h2
. This will likely have implications to focus state and possibly screen-readers, as we should be focusing on the h2
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its maybe more of an accessibility question, I feel like we should be focusing on the h2
element but maybe its ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could raise it as a bug or improvement if @greenc05 thinks we should?
…ent-2' of github.com:bbc/simorgh into WSTEAMA-1417-add-related-content-link-to-jump-to-component-2
…ump-to-component-2
…ent-2' of github.com:bbc/simorgh into WSTEAMA-1417-add-related-content-link-to-jump-to-component-2
…ump-to-component-2
…ent-2' of github.com:bbc/simorgh into WSTEAMA-1417-add-related-content-link-to-jump-to-component-2
…ump-to-component-2
@amoore108 I need to increase the max bundle size for the article page by 1kb apparently. or is there another way of preventing this? |
The output says:
Curious why its gone up with this change. There are quite a few diffs to the ArticlePage component though, are they all needed? Looks like linting and console logs. The I'd make those changes before adjusting the bundle size to see if that helps. |
This is from my PR, so I would change the MIN/MAX values in the bundleSizeConfig to the values from the build output in this PR. The Its likely just slowly creeped up and is now getting caught by these min/max values. |
I have removed the remaining dregs from Blocks and the console log from Article Page, but there is still the bundle size issue. In the comparison of the file in github it looks like loads of changes to the file, but almost all of it isn't actually a change and is just the code is on different lines due to adding
which shifts things down. Makes it hard to see the real differences, but there aren't actually many! |
const showRelatedContentLink = | ||
!!pidginArticleFixtureWithJumpToBlock.data.article.content.model.blocks.find( | ||
block => block.type === 'relatedContent', | ||
); | ||
return ( | ||
<Component | ||
jumpToHeadings={jumpToHeadings} | ||
showRelatedContentLink={showRelatedContentLink} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth deleting the blocks.find
stuff and just having a separate story for the related content link?
Like:
<Component
jumpToHeadings={jumpToHeadings}
showRelatedContentLink={false}
/>
...
<Component
jumpToHeadings={jumpToHeadings}
showRelatedContentLink
/>
Still a bit concerned about #12157 (comment), we're focusing on the |
|
||
if ( | ||
showRelatedContentLink && | ||
!jumpToHeadings?.some(({ heading }) => heading === relatedContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this part of the condition ever be hit? Or was there a re-rendering thing happening whereby its was adding relatedContent
to the array multiple times?
If thats happening, we should try not to mutate the original data, instead taking a copy of the jumpToHeadings
and then pushing the relatedContent
item to the copy, not the original.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was adding the link again each rerender. I have been working on trying the copy of the array in storybook as it happens there too. I will do the same in this code too when I have got it working 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it may be good to try and construct an array of 'things to render', including the related content if applicable, so something like:
const headingsToRender = [
// Article subheadings
...jumpToHeadings.map(({ heading }) => ({
heading,
id: idSanitiser(heading),
})),
// Related content
showRelatedContentLink && {
heading: relatedContent,
id: 'section-label-heading-related-content-heading',
},
];
That'll take a shallow copy of the jumpToHeadings
, so shouldn't cause the original data to be mutated and keep appending items to it on re-renders.
…ump-to-component-2
Resolves JIRA [number]
Overall changes
A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.
Code changes
Testing
Helpful Links
Add Links to useful resources related to this PR if applicable.
Coding Standards
Repository use guidelines