Repository navigation
fix: resolve hierarchy path ancestors using the request draft intent - #17269
Open
thribhuvan003 wants to merge 1 commit into
Open
thribhuvan003 wants to merge 1 commit into
thribhuvan003 wants to merge 1 commit into
Conversation
Contributor
|
Hi @thribhuvan003, Thanks for the PR addressing my issue! That said, I think the more robust and safer fix would be to expose the "draft" argument to the hook, as suggested in the issue: #16180. |
Author
|
hey, thanks for taking a look! i agree exposing |
This branch has not been deployed
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.
What?
When a hierarchy collection document is read with
draft: true, the computed_h_slugPath/_h_titlePathnow resolve the ancestor chain at the draft version the request asked for. Previously the draft flag passed tocomputePathscame from the document's own_status.Why?
doc._statusonly says whether this specific document has unpublished changes, it says nothing about the request. So a published child read in live preview (draft: true) walked its ancestors withdraft: falseand got the published parent titles/slugs. With a parent that had a draft-only rename, the child's breadcrumb showed the published slug instead of the draft one.How?
The hierarchy plugin's own
beforeOperationhook already runs for read operations and receives the operation args, so it now stashesargs.draftincontext.hierarchyRequestDraft(same pattern as the existingcomputeHierarchyPathsViaSelectflag).afterReadprefers that value and only falls back to the olddoc._status === 'draft'check for paths that don't go through a read operation.draftis already a boolean by the time the hook runs on every surface (REST coerces it viaparseParams, local API and GraphQL pass it directly).Added an int test: published parent with a draft-only rename plus a published child. Reading the child with
draft: trueyields the draft parent path, and withdraft: falsestill yields the published one. The first assertion fails without the fix, the full hierarchy suite (35 tests) passes with it.Fixes #17223