Skip to content

Conversation

ApsiV11
Copy link
Contributor

@ApsiV11 ApsiV11 commented Sep 5, 2025

This PR fixes two bugs in the version diff view SetStepNav component

Bug 1: Document title isn't shown correctly in the step navigation if the field of useAsTitle is nested inside a presentational field.

The StepNav shows the title of the document consistently throughout every view except the version diff view. In the version diff view, the document title is always [Untitled] if the field of useAsTitle is nested inside presentational fields. Below is a video demo of the bug:

Before.mov

This happens because the fields of the collection/global aren't flattened inside SetStepNav and thus the component is not accessing the field data correctly. This results in the title being null causing the fallback title to be shown.

Bug 2: Step navigation shows the title of the version viewed, not the current version

The StepNav component takes the title of the current version viewed. This causes the second part of the navigation path to change between versions which is inconsistent between other views and doesn't seem intentional, although it could be. Below is a video of the bug with the first bug fixed by flattening the fields:

FieldsFixed.mov

This happens due to the fact that the title is taken from the useAsTitle field of the viewed version rather than the current version. This bug is fixed by using the useDocumentTitle hook from the ui package instead of passing the version's useAsTitle data down the component tree. The final state of the step navigation is shown in the following video:

After.mov

I also added a test to test that the title part in the step navigation stays consistent between versions and implicitly also tests that the document title is shown correctly in the step nav if the field of useAsTitle is a nested inside a presentational field.

The title also works when useAsTitle field is nested inside group or tabs
Copy link
Member

@AlessioGr AlessioGr left a comment

Choose a reason for hiding this comment

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

This is great, thank you! Well done!

@AlessioGr AlessioGr merged commit 794bf82 into payloadcms:main Sep 5, 2025
85 checks passed
Copy link
Contributor

github-actions bot commented Sep 9, 2025

🚀 This is included in version v3.55.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants