Overview
I've added some more minimal steps to reproduce in the comments - @jessebaker
When editing the Hero component in the XB, if the button labels are renamed (for example, "View" to "Accept" and "Click" to "Decline"), the changes initially reflect correctly in both the preview and the editing slide.
However, after selecting a renamed button (like "Accept") and pressing the Tab key twice, the button labels in the preview revert back to their original values ("View" and "Click"), while the editing slide still displays the renamed labels ("Accept" and "Decline").
This creates a mismatch between the preview and the editor panel.
Steps to Reproduce:
- Drag and drop a Hero component onto the canvas.
- Rename the button labels:
- Change "View" to "Accept"
- Change "Click" to "Decline"
- Click into the "Accept" button field in the editing slide.
- Press the Tab key twice.
- Observe the issue:
- In the preview, the button labels revert to "View" and "Click".
- In the editing slide, the labels still display "Accept" and "Decline".
Proposed resolution
User interface changes
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2025-05-07 16.19.18.gif | 240.92 KB | jessebaker |
| #5 | Screen Recording 2025-04-29 at 3.21.47 PM.mov | 19.66 MB | mayur-sose |
| #3 | Screenshot from 2025-04-22 16-58-20.png | 105.08 KB | bhumikavarshney |
| #3 | Screenshot from 2025-04-22 16-57-39.png | 40.93 KB | bhumikavarshney |
Issue fork experience_builder-3519734
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3519734-ref-approach
changes, plain diff MR !1005
- 3519734-blur-on-the
changes, plain diff MR !997
Comments
Comment #2
wim leersInteresting find! Not sure yet if this is a client-side or server-side bug. But since the server side renders the preview for the component tree it receives, I suspect it's the client side. If it's the server side, then I suspect it's in the auto-save functionality.
Comment #3
bhumikavarshney commentedHi
I tried to reporduce the issue but not able to reporcude the same.
I edited the button and followed the steps added above.
But in preview i can see the same text which we added.
please refer the screenshots
Comment #4
wim leersThanks, @bhumikavarshney!
Comment #5
mayur-sose commentedComment #6
wim leersDefinitely a bug! 👍 Thanks! 🙏
This is either a bug on the back-end (internal HTTP API or Auto-save), in the client-side handling of Auto-save, or in the Redux-integrated field widgets. Can you please attach the request body that was sent to generate that form when it was broken? 🙏
Comment #7
mayur-sose commentedBelow is the request payload (when it was broken) :
Comment #8
mayur-sose commentedComment #9
lauriiiI was able to reproduce this! This is critical because of data loss.
Comment #10
jessebaker commentedWhen editing the Hero component that is bundled with XB
1. Update the values of some of the fields
2. Observe that the preview is updated with those changes
3. Focus into and then focus out of the "CTA 1 link" (autocomplete) field
4. Observe that, while the form values remain updated, the preview reverts back to before the changes made in step 1.
If you view the network request that occurs on blur you can see that the data sent as PATCH to the server contains the starting values of the form, not the updated ones.
Comment #13
omkar-pd commentedAdding
attributes.onChangein dependency array fixes the issue.While this causes the effect to run multiple times as
onChangereference update, but I think it's necessary to ensure event handlers always have access to the current state.Comment #14
omkar-pd commentedOr we could use useRef to fix the issue
Comment #15
omkar-pd commentedComment #16
bnjmnmGood idea. Lets do that to minimize
useEffect, even if it means a bit of extra logic.Comment #19
bnjmnmAdded
3519734-ref-approach, first commit is an intentionally failing test and the second commit is a version of the ref approach suggested by @omkar-pd in #14Comment #22
bnjmnmWith @larowlan approval this can be merged.