Skip to content

Conversation

EsariUp
Copy link
Collaborator

@EsariUp EsariUp commented Jul 2, 2025

Description / Motivation

This change updates the Razor view to ensure that the timeline section is only rendered when there are timeline events available. Previously, the timeline container was always rendered, even if no events were present, which could result in empty or misleading UI sections.

This improves the user experience by displaying relevant content only when available and avoids rendering unnecessary HTML markup.

How Has This Been Tested?

  • Manually tested the profile view with and without timeline events.
    Verified that:
  • The timeline section appears only when Model.GetTimelineEvents() returns items.
  • The section is hidden when the timeline is empty or null.
  • Tested in local development environment using Visual Studio 2022.
  • Confirmed that no layout or styling issues occur due to conditional rendering.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the Contributing guide.
  • My code/comments/docs fully adhere to the Code of Conduct.
  • My change is a code change.
  • My change is a documentation change and there are NO other updates required.

<partial name="Components/Profile/_Timeline" model="Model.GetTimelineEvents()" />
</div>
</div>
@if (Model.GetTimelineEvents()?.Any() == true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont like the comparison to true here as it feels like it's hiding the fact that the code is stating that GetTimelineEvents() could be null.

Can we change this use a Null-Coalescing operator instead?

e.g.

@if (Model.GetTimelineEvents()?.Any() ?? false)

@robearlam robearlam linked an issue Jul 6, 2025 that may be closed by this pull request
@robearlam robearlam merged commit a721222 into Sitecore:main Jul 6, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Timeline if no item is listed
2 participants