Gotcha! Components in Shared regions don’t receive the recordId

This is for Shared Regions (like header, navbar, footer) in the Community app builder:

Community Builder Shared Regions
Community Builder Shared Regions

Today I learnt that if your component implements force:hasRecordId then it won’t get a record ID, even if you’re on an Account page for example.

Secondly – these shared regions are not re-rendered during navigation – which is obviously great for performance reasons 🙂

Why would a component in the shared areas want the recordId?

My use case for this is pretty simple- my Navigation Bar has some shortcuts to specific Products, so if the user ends up on the Product page (either by clicking directly or from a Search), then I want my nav bar to highlight that we’re now looking at that Product!

So, how can we workaround this limitation and have a component in the shared region get the recordId?

Continue reading “Gotcha! Components in Shared regions don’t receive the recordId”