Skip to content

Hotfix v0.4.1: M2M pivot 403 + collection-switch stale fields (Issue #55)#58

Merged
smartlabsAT merged 11 commits into
mainfrom
hotfix/v0.4.1-issue-55-m2m-collection-switch
May 24, 2026
Merged

Hotfix v0.4.1: M2M pivot 403 + collection-switch stale fields (Issue #55)#58
smartlabsAT merged 11 commits into
mainfrom
hotfix/v0.4.1-issue-55-m2m-collection-switch

Conversation

@smartlabsAT
Copy link
Copy Markdown
Owner

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}.name against the junction collection — which typically has no name column → 403 Forbidden, table did not render.

Root cause: the case 'related-values': branch in adjustFieldsForDisplays.ts did not traverse junction_field like 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 reactive Ref. Directus core's signature is useCollection(collectionKey: string | Ref<string | null>) — passing the Ref is 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 in EditableCellRelational.vue only ran for override/heuristic-sourced templates, not for meta.display: 'related-values'.

Bug 1c — Primitive override template (found via E2E)

A columnDisplays override pointing at a non-relational field (e.g. template {{name}} on the string field name) returned em-dash. The override path only handled arrays/objects.

Architectural notes

Test plan

  • Unit tests: 195/195 passing.
  • TypeScript + ESLint + Prettier clean.
  • pnpm build succeeds.
  • E2E proof script (playwright-tools/project-specific/issue-55-e2e-proof.js) — captured the 403 on main and the 200 with correct junction path on this branch, side by side.
  • Full E2E (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.
  • Verified against a real M2M test setup with a junction collection that has no name field (the issue Bug: Extension requests non-existent field in M2M pivot table causing 403 errors #55 trigger condition).

…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.
@github-actions
Copy link
Copy Markdown

Quality Check Results

TypeScript 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

@smartlabsAT smartlabsAT merged commit 1aae481 into main May 24, 2026
18 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.

Bug: Extension requests non-existent field in M2M pivot table causing 403 errors

1 participant