Skip to content

Commit b2ba0ea

Browse files
authored
Merge pull request #54 from smartlabsAT/hotfix/v0.3.2-issue-44
Hotfix v0.3.2: Inline edit silently failing on non-id primary keys (#44)
2 parents 1431110 + f7b1315 commit b2ba0ea

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ All notable changes to the Super Layout Table Extension will be documented in th
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.3.1] - 2026-05-09
8+
## [0.3.2] - 2026-05-09
9+
10+
### Fixed
11+
- **Inline editing silently failing for collections with non-`id` primary key
12+
(Issue #44).** `handleUpdate` and `handleBooleanToggle` in
13+
`EditableCellRelational.vue` were detecting the primary key by name pattern
14+
matching (`key === 'id' || key.endsWith('_id')`), which produced no result on
15+
collections whose primary key uses a different name (`code`, `slug`, `uuid`,
16+
`sku`, …). Both functions now read the primary key field name from the
17+
`primaryKeyField` computed property, which is sourced from the Directus
18+
schema via the parent component. The previous heuristic could also have
19+
selected an unrelated foreign-key column ending in `_id` and dispatched the
20+
PATCH against the wrong record; that misdirection is no longer possible.
21+
22+
923

1024
### Changed
1125
- Bumped 21 development dependencies to their latest patch versions within

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "directus-extension-super-table",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "A powerful and feature-rich table layout extension for Directus 11+ with inline editing, quick filters, and manual sorting",
55
"keywords": [
66
"directus",

src/components/EditableCellRelational.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,13 @@ function renderTemplate(value: any, template: string): string {
610610
}
611611
612612
function handleUpdate(value: any) {
613-
const primaryKey = Object.keys(props.item).find((key) => key === 'id' || key.endsWith('_id'));
613+
const itemId = props.item?.[primaryKeyField.value];
614614
615-
if (primaryKey) {
615+
if (itemId !== undefined && itemId !== null) {
616616
// Check if this is a full translations update
617617
if (typeof value === 'object' && value?.isFullTranslations) {
618618
// Handle full translations update from interface-translations
619-
emit('update', props.item[primaryKey], 'translations', {
619+
emit('update', itemId, 'translations', {
620620
isFullTranslations: true,
621621
translations: value.translations,
622622
});
@@ -631,17 +631,17 @@ function handleUpdate(value: any) {
631631
language: fieldLanguage.value, // Use language from field key or selected
632632
isTranslation: true,
633633
};
634-
emit('update', props.item[primaryKey], props.fieldKey, translationUpdate);
634+
emit('update', itemId, props.fieldKey, translationUpdate);
635635
} else {
636-
emit('update', props.item[primaryKey], props.fieldKey, value);
636+
emit('update', itemId, props.fieldKey, value);
637637
}
638638
}
639639
}
640640
641641
function handleBooleanToggle(value: boolean) {
642-
const primaryKey = Object.keys(props.item).find((key) => key === 'id' || key.endsWith('_id'));
643-
if (primaryKey) {
644-
emit('update', props.item[primaryKey], props.fieldKey, value);
642+
const itemId = props.item?.[primaryKeyField.value];
643+
if (itemId !== undefined && itemId !== null) {
644+
emit('update', itemId, props.fieldKey, value);
645645
}
646646
}
647647

0 commit comments

Comments
 (0)