fix(next): version diff view shows correct document title in step nav #13713
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.
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 ofuseAsTitle
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 theuseDocumentTitle
hook from the ui package instead of passing the version'suseAsTitle
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.