Hotfix v0.4.1: M2M pivot 403 + collection-switch stale fields (Issue #55)#58
Merged
Merged
Conversation
…witch regression)
…rce + primitive override path The display rendering had two latent bugs surfacing in the issue #55 setup: 1. M2M unwrap (mapping junction items through junction_field before applying the template) only ran for override- and heuristic-sourced templates, skipping the field-settings-display path. Result: with display set to related-values + template {{name}}, the template would look up 'name' on the pivot row (which has no 'name') and leak the literal {{name}}. 2. A column-display override on a simple, non-relational field (e.g. template {{name}} on a string field 'name') fell through to a primitive-value fallback that returned em-dash. The template should apply to the primitive directly.
Quality Check ResultsTypeScript Type Check✅ Passed - No type errors found ESLint✅ Passed - No linting errors Prettier Format Check✅ Passed - Code is properly formatted Build✅ Passed - Extension builds successfully Updated: 2026-05-24T08:40:04.402Z |
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.
Closes #55.
Summary
Fixes two distinct bugs reported in #55, plus two related display-rendering issues discovered during E2E verification.
Bug 1 — M2M pivot 403 (original report)
With a M2M field configured to
display: 'related-values'+ template{{name}}, the extension queried${field}.nameagainst the junction collection — which typically has nonamecolumn → 403 Forbidden, table did not render.Root cause: the
case 'related-values':branch inadjustFieldsForDisplays.tsdid not traversejunction_fieldlike the override and heuristic branches already did.Bug 2 — Collection-switch stale fields (@draxx318's comment on #55)
Navigating between two collections that both use Super Table caused the new collection to be queried with the previous collection's field list → 403.
Root cause:
useCollection(collection.value)extracted a static string snapshot instead of passing the reactiveRef. Directus core's signature isuseCollection(collectionKey: string | Ref<string | null>)— passing theRefis the canonical reactive pattern.Bug 1b — M2M display rendering (found via E2E)
With Bug 1 fixed, the API returned correct M2M data — but the template
{{name}}still leaked as a literal in the cell. The junction-row unwrap inEditableCellRelational.vueonly ran for override/heuristic-sourced templates, not formeta.display: 'related-values'.Bug 1c — Primitive override template (found via E2E)
A
columnDisplaysoverride pointing at a non-relational field (e.g. template{{name}}on the string fieldname) returned em-dash. The override path only handled arrays/objects.Architectural notes
expandTokensThroughRelation()inadjustFieldsForDisplays.tsis now the single source of truth for token-to-path expansion across the override, heuristic, andrelated-valuesbranches. Closes the drift class behind Bug: Extension requests non-existent .title field in translations causing errors #34 (.titleon translations) and Bug: Extension requests non-existent field in M2M pivot table causing 403 errors #55 (.nameon M2M junction).useCollectionswitched from static-string to reactiveRefper Directus core's documented signature.Test plan
pnpm buildsucceeds.playwright-tools/project-specific/issue-55-e2e-proof.js) — captured the 403 onmainand the 200 with correct junction path on this branch, side by side.issue-55-full-e2e.js) — 6 scenarios PASS: M2M render, 5-step collection-switch, regression on 5 existing collections, edit-mode toggle, detail-row navigation.namefield (the issue Bug: Extension requests non-existent field in M2M pivot table causing 403 errors #55 trigger condition).