Split model values into resolved and raw

Created on 13 December 2024, 5 days ago

Overview

In πŸ› Some components cannot be used in XB because UI prevents SDC props being named `name` Active we've identified that we need to keep the raw model values as well as the resolved values.
The resolved values are what end up in the UI for rendering the component.
The raw values are what end up in the component tree field item.
E.g. for a media image reference that might be

[
            'alt' => 'This is a random image.',
            'width' => 100,
            'height' => 100,
            'target_id' => (int) $this->mediaEntity->id(),
]

But the resolved value the page builder needs to show the preview is

[
            'src' => '/path/to/some/image.webp',
            'alt' => 'This is a random image.',
            'width' => 100,
            'height' => 100,
],

Proposed resolution

Split the component model values into raw and resolved.

User interface changes

πŸ“Œ Task
Status

Active

Version

0.0

Component

Page builder

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @larowlan
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Split the component model values into raw and resolved.

    To make sure I don't misunderstand: you're saying that this is necessary on the client-side, i.e. in the UI's data model?

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Also, AFAICT this relates to πŸ“Œ Move form state into the global store Active too? Is that a third kind of value?

    • raw: as stored in a FieldType plugin on the server side
    • resolved: as resolved into a shape expected by an SDC prop
    • form: as represented by a FieldWidget for a FieldType, aka πŸ“Œ Move form state into the global store Active

    … or am I misinterpreting things now? πŸ˜…

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Yes, client side - we post a model to the preview and form endpoints and there's some hard-coded stuff happening with e.g. images to flip them back from a file URL to a target ID. Look at \Drupal\experience_builder\Controller\ClientServerConversionTrait::findTargetForProps for example - that can only go away if the client-side model stores a reference to

    [
                'alt' => 'This is a random image.',
                'width' => 100,
                'height' => 100,
                'target_id' => (int) $this->mediaEntity->id(),
    ]
    

    As well as

    [
                'src' => '/path/to/some/image.webp',
                'alt' => 'This is a random image.',
                'width' => 100,
                'height' => 100,
    ],
    

    In terms of the form state, that is only a global place to store the current form values before we commit them to the model. Previously it was done via a context provider but that didn't work for ajax form additions - the global state does

Production build 0.71.5 2024