Skip to content

Commit e48f7cb

Browse files
mynetxclaude
andcommitted
Fix relationship-based fields showing raw ids after saving
When the publish form resets values from a save response, ids may come back in a different form than what the client selected — most visibly when typing a new term into a single-term select field, where the typed text gets normalized to a taxonomy::slug id the component has no item data for. The item then renders its raw id instead of its title until a full reload. Refetch item data whenever the value references items missing from it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent bc8744c commit e48f7cb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

resources/js/components/inputs/relationship/RelationshipInput.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ export default {
234234
itemData(data, olddata) {
235235
if (this.initializing) return;
236236
this.$emit('item-data-updated', data);
237+
},
238+
239+
value(value) {
240+
if (this.initializing || this.loading) return;
241+
242+
// Values set from outside (e.g. from a save response, where a new term's id gets
243+
// normalized) may reference items we have no data for, which would display raw ids.
244+
if (value?.some(selection => !_.find(this.data, (item) => item.id == selection))) {
245+
this.getDataForSelections(value);
246+
}
237247
}
238248
239249
},

0 commit comments

Comments
 (0)