- 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 aFieldType
plugin on the server sideresolved
: as resolved into a shape expected by an SDC propform
: as represented by aFieldWidget
for aFieldType
, 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
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
I believe this change is critical for XB in the future, because it'll make a lot of magic (see the method mentioned by Lee) explicit. Bumping priority.
- 🇺🇸United States effulgentsia
✨ [PP-1] Make link widget autocomplete work (for uri and uri-reference props) Postponed could also be a good example for verifying what gets implemented here.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
This is blocked on 📌 Maintain a per-component set of prop expressions/sources Active which is also blocked, updating status.
Updating the title to reflect this is about default values now as 📌 Maintain a per-component set of prop expressions/sources Active includes values in the prop source data.
Once that is in, we will need default values to cover both. e.g. If we've got an image reference, the default value of the hydrated props might be a URL, alt tag and width and height, but the stored value would be the media or file ID.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
📌 Maintain a per-component set of prop expressions/sources Active is no longer postponed.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
📌 Maintain a per-component set of prop expressions/sources Active is in.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
We're threading very closely to this over in the MR for 🐛 Adding the Image component results in a state considered invalid Active .
- Assigned to larowlan
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
The need for this was confirmed by @larowlan at #3501902-67: Adding the Image component results in a state considered invalid → .
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
I just created 📌 Clarify default 'resolved' vs 'source' value logic in GeneratedFieldExplicitInputUxComponentSourceBase::getClientSideInfo() Active , which I believe will make this issue much simpler, because with that done, the server-side pieces will already exist.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
We ran into the actual real-world need for this: #3507929-25: [Front-end] Allow adding "image" props in the code component editor → .
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Bumping priority given this is in the critical path.
I bet this will also help solve 🐛 Default image is lost after changing props Active and 🐛 No visible error message when trying to save with missing image Active .
- 🇬🇧United Kingdom longwave UK
Been thinking about this on and off for a while now. I agree that we need the raw values available to the client side UI, because in the case of
[ 'alt' => 'This is a random image.', 'width' => 100, 'height' => 100, 'target_id' => (int) $this->mediaEntity->id(), ]
we need to send and receive the target_id for the media library form. This is the root cause of 🐛 Error when adding a section to the page Active - see Felix's investigation in #7.
Do we only need resolved values for component preview and final render? I have concerns that if we are storing/sending both raw and resolved then there is a chance of them getting out of sync - either accidentally, or deliberately if someone is trying to mess with the values, which might have security implications.
So in the layout API we would only send the layout + raw values to the client, the client stores and sends raw values back for forms (which is all we need anyway) and previews (which we translate at preview time into the resolved values). If this is correct, where do we need resolved values in the client side model?
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
If we can get rid of findTargetForProps then I'm open to all ideas
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
#21: right, but as you already wrote in #4 >3 months ago and again confirmed in #7, that's exactly what this issue will make possible.
Let's get this done ASAP, this would've prevented me having spent hours on 🐛 Default image is lost after changing props Active today. 😬
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
As described in #3508077-28: Default image for SDC with optional image is lost after changing value for another SDC prop → : there's a front-end bug lurking that causes some props'
source
s to not be passed from the client to the server, even though they should be set to the default as returned by/xb/api/config/component
: https://git.drupalcode.org/project/experience_builder/-/merge_requests/7... - 🇺🇸United States effulgentsia
Do we only need resolved values for component preview and final render? I have concerns that if we are storing/sending both raw and resolved then there is a chance of them getting out of sync
I agree. Ideally only the raw values would need to be passed from the client to the server. As to where within the React code the resolved values are needed at all, as well as whether or not it's needed for resolved values (in addition to raw values) to be passed from server to client, I opened ✨ Real-time preview for props changes of JS components Active . That issue should be relatively straightforward to do, and I wonder if it would help with this issue's implementation to do that one first, to make sure resolved values are being used somewhere within the React code, even if not as part of the HTTP API.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
First: please check 📌 Support server side massage and validation of component prop form values Active for why @larowlan introduced
source
in addition to the pre-existingresolved
. @longwave in #20's comment seems to suggest XB stores both, but that's not the case! We only store thesource
in the DB — theresolved
really just dates back to the super simple client-side data model we had until before that issue.I don't see how ✨ Real-time preview for props changes of JS components Active would A) help this issue, B) be relatively straightforward?
Yes, the
resolved
value is currently not yet actively used on the client-side, and we could in theory remove it. But there's little value in doing that, because 📌 Implement endpoint for realtime preview Active will need bothresolved
andsource
. Yes, ✨ Real-time preview for props changes of JS components Active would/could/should be the first thing to actually useresolved
for client-side functionality rather than sending it back to the server! 👍But ✨ Real-time preview for props changes of JS components Active kinda can't be straightforward — you already mentioned the auto-save implications, I just added another: undo/redo → #3514910-2: Real-time preview for props changes of JS components → .
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Overhauled issue summary to reflect the names that have been chosen in 📌 Support server side massage and validation of component prop form values Active , and what the remaining work here is.
- 🇺🇸United States effulgentsia
I don't see how #3514910: Real-time preview for props changes of JS components would A) help this issue...Yes, the resolved value is currently not yet actively used on the client-side, and we could in theory remove it.
My thinking was that the help it would offer this issue is by having an implemented use case (with tests) of the resolved values being used. So that, a) it prevents them from being removed, and b) it allows refactoring of where they're kept if such refactoring is desired per #20 while continuing to ensure that such refactoring is compatible with the use-case they need to serve.
But I'm totally okay with this issue being worked on first and not postponing it on ✨ Real-time preview for props changes of JS components Active .
- Merge request !814#3493943: split default values into `resolved` and `source` → (Merged) created by longwave
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Annotated the MR
Two open threads, one to file a dedicated issue for the data corruption issue and another to review the use of
empty
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
The only open thread is to open a dedicated issue, this is green and ready for review
- 🇬🇧United Kingdom longwave UK
One nit with test formatting but otherwise no notes, this looks great - good find on that stored data vs later shape change bug, thanks also for the detailed self-review.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
🐛 Component transforms need to be per sourceType, not per component prop Active for the critical found in the final test fail
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Postponed 🐛 Component transforms need to be per sourceType, not per component prop Active on this
- 🇬🇧United Kingdom longwave UK
Feedback addressed, added another followup as per discussion, back to RTBC.
Waiting on this to land before I try to move the other image issues forward because this is intertwined with some of them.
- 🇬🇧United Kingdom longwave UK
Found a bug when testing this with xb-demo, see MR.
However the server side performance issues with xb-demo are just gone with this patch, the 70 calls to
GeneratedFieldExplicitInputUxComponentSourceBase::getClientSideInfo()
now take 92ms down from 21,158ms - a 230x speed improvement :D - 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Addressed all feedback, thanks for the review
- 🇬🇧United Kingdom longwave UK
All points addressed, no further feedback - over to Wim for hopefully the final review.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
We fixed a complex set of problems by net-deleting code: MR diffstat is
+208, −325
🥳😄Plus, now section
3.2.1 Source vs resolved input
indocs/redux-integrated-field-widgets.md
is actually completely accurate and doesn't even need to spell out that the same is true for the default values — that just makes sense, it's the situation before this MR that didn't make sense! (Well, just was unfinished/inconsistent.)work here! 🤩
-
wim leers →
committed 3535fb59 on 0.x authored by
longwave →
Issue #3493943 by larowlan, wim leers, longwave: SDC+JS Component...
-
wim leers →
committed 3535fb59 on 0.x authored by
longwave →
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
With this in, updated/unpostponed:
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Found a regression: 🐛 Regression caused by #3493943: example/default image in SDC no longer loads Active .
- Issue was unassigned.
- Status changed to Fixed
5 days ago 2:59pm 25 April 2025 Automatically closed - issue fixed for 2 weeks with no activity.