WS-2117 Add lightweight contextual navigation attribution#14228
Draft
LilyL0u wants to merge 5 commits into
Draft
WS-2117 Add lightweight contextual navigation attribution#14228LilyL0u wants to merge 5 commits into
LilyL0u wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://bbc.atlassian.net/browse/WS-2117
i have updated this so that the home tab is highlighted when watch or listen is not highlighted, so it acts as a default or fallback.
This pull request enhances the navigation highlighting logic to more accurately reflect the user's current page context, especially for media pages (audio/video). The main improvement is the introduction of page-type and media-type-based attribution for navigation highlighting, ensuring that "Watch" or "Listen" are highlighted when appropriate, rather than always defaulting to "Home" or having nothing highlighted. This is achieved through changes in the navigation logic by passing the detected primary media type through the component tree for article pages containing media.
Navigation logic improvements:
getActiveTopIndexinNavigation/index.tsxto use page type and detectedprimaryMediaTypeto determine which top navigation item ("Home", "Watch", or "Listen") should be highlighted. This ensures that, for example, video pages highlight "Watch" and audio pages highlight "Listen", with sensible fallbacks when those items are not present. [1] [2]primaryMediaTypeis now detected inPageLayoutWrapper/index.tsxby inspectingblockTypesand content blocks, and is passed down throughHeaderContainertoNavigation. [1] [2] [3] [4]Test coverage improvements:
Navigation/index.test.tsxto verify correct navigation highlighting for a wide variety of page and media types, including articles, topics, TV, live TV, media articles, audio, and live radio pages, with and without corresponding navigation items.Type and prop updates:
PageLayoutWrapper,HeaderContainer, andNavigationcomponents to support the newprimaryMediaTypeprop. [1] [2] [3]Imports and constants:
These changes collectively ensure that navigation highlighting is context-aware, improving usability for users on media-rich pages.Resolves
A weakness of this method is that it relies on the order of the top nav always being: (1) Home, (2) Watch, (3) Listen, as the links in these items can be urls with no indication of what media they contain. The text on them also comes from the BFF, rather than being translated in Simorgh, so unless we translate the text, we don't know what it says to map it to which item it is.
It should work for radio pages, tv pages, and article and media article pages containing media.
Testing
Some example URLs
http://localhost:7081/afrique/articles/crevwjxjdgyo?renderer_env=live
http://localhost:7081/afrique/articles/cd9wdkqjgk9o?renderer_env=live
http://localhost:7081/afrique/bbc_afrique_radio/w1730k9s84l43h7?renderer_env=live
Useful Links