diff --git a/CHANGELOG.md b/CHANGELOG.md index 5768dc1..1f6573f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,21 @@ All notable changes to the Super Layout Table Extension will be documented in th The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.3.1] - 2026-05-09 +## [0.3.2] - 2026-05-09 + +### Fixed +- **Inline editing silently failing for collections with non-`id` primary key + (Issue #44).** `handleUpdate` and `handleBooleanToggle` in + `EditableCellRelational.vue` were detecting the primary key by name pattern + matching (`key === 'id' || key.endsWith('_id')`), which produced no result on + collections whose primary key uses a different name (`code`, `slug`, `uuid`, + `sku`, …). Both functions now read the primary key field name from the + `primaryKeyField` computed property, which is sourced from the Directus + schema via the parent component. The previous heuristic could also have + selected an unrelated foreign-key column ending in `_id` and dispatched the + PATCH against the wrong record; that misdirection is no longer possible. + + ### Changed - Bumped 21 development dependencies to their latest patch versions within diff --git a/package.json b/package.json index cd3161a..b01d7db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "directus-extension-super-table", - "version": "0.3.1", + "version": "0.3.2", "description": "A powerful and feature-rich table layout extension for Directus 11+ with inline editing, quick filters, and manual sorting", "keywords": [ "directus", diff --git a/src/components/EditableCellRelational.vue b/src/components/EditableCellRelational.vue index d51888f..f3ff997 100644 --- a/src/components/EditableCellRelational.vue +++ b/src/components/EditableCellRelational.vue @@ -610,13 +610,13 @@ function renderTemplate(value: any, template: string): string { } function handleUpdate(value: any) { - const primaryKey = Object.keys(props.item).find((key) => key === 'id' || key.endsWith('_id')); + const itemId = props.item?.[primaryKeyField.value]; - if (primaryKey) { + if (itemId !== undefined && itemId !== null) { // Check if this is a full translations update if (typeof value === 'object' && value?.isFullTranslations) { // Handle full translations update from interface-translations - emit('update', props.item[primaryKey], 'translations', { + emit('update', itemId, 'translations', { isFullTranslations: true, translations: value.translations, }); @@ -631,17 +631,17 @@ function handleUpdate(value: any) { language: fieldLanguage.value, // Use language from field key or selected isTranslation: true, }; - emit('update', props.item[primaryKey], props.fieldKey, translationUpdate); + emit('update', itemId, props.fieldKey, translationUpdate); } else { - emit('update', props.item[primaryKey], props.fieldKey, value); + emit('update', itemId, props.fieldKey, value); } } } function handleBooleanToggle(value: boolean) { - const primaryKey = Object.keys(props.item).find((key) => key === 'id' || key.endsWith('_id')); - if (primaryKey) { - emit('update', props.item[primaryKey], props.fieldKey, value); + const itemId = props.item?.[primaryKeyField.value]; + if (itemId !== undefined && itemId !== null) { + emit('update', itemId, props.fieldKey, value); } }