Skip to content

Commit

Permalink
[5.x] Fix replicator preview for Group fields (statamic#11280)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
duncanmcclean and jasonvarga authored Dec 18, 2024
1 parent 42c3804 commit f44afc5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/js/components/fieldtypes/GroupFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
:errors="errors(field.handle)"
:field-path="fieldPath(field.handle)"
:read-only="isReadOnly"
:show-field-previews="config.replicator_preview"
@updated="updated(field.handle, $event)"
@meta-updated="updateMeta(field.handle, $event)"
@focus="$emit('focus')"
@blur="$emit('blur')"
@replicator-preview-updated="previewUpdated(field.handle, $event)"
/>
</div>
</div>
Expand All @@ -57,18 +59,21 @@
import Fieldtype from './Fieldtype.vue';
import SetField from './replicator/Field.vue';
import { ValidatesFieldConditions } from '../field-conditions/FieldConditions.js';
import ManagesPreviewText from "./replicator/ManagesPreviewText";
export default {
mixins: [
Fieldtype,
ValidatesFieldConditions,
ManagesPreviewText,
],
components: { SetField },
data() {
return {
containerWidth: null,
focused: false,
fullScreenMode: false,
previews: {},
provide: {
group: this.makeGroupProvide(),
storeName: this.storeName,
Expand All @@ -86,7 +91,7 @@ export default {
replicatorPreview() {
if (! this.showFieldPreviews || ! this.config.replicator_preview) return;
return Object.values(this.value).join(', ');
return replicatorPreviewHtml(this.previewText);
},
internalFieldActions() {
return [
Expand Down Expand Up @@ -150,6 +155,10 @@ export default {
this.$emit('meta-updated', { ...this.meta, [handle]: value });
},
previewUpdated(handle, value) {
this.previews = { ...this.previews, [handle]: value };
},
fieldPath(handle) {
return (this.fieldPathPrefix || this.handle) + '.' + handle;
},
Expand Down

0 comments on commit f44afc5

Please sign in to comment.