-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow saving in FSE for Form Options #1834
Conversation
Bundle Size Diff
|
Plugin build for e77fe2d is ready 🛎️!
|
E2E SummaryTyping
Values above 60ms"0 - 66.42, 9 - 61.04, 12 - 61.33, 16 - 61.74" |
All good here or any changes required @Soare-Robert-Daniel? |
@HardeepAsrani I am now investigating how to allow saving on the Widgets page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can fix the merge conflicts and put it up for QA, thank you @Soare-Robert-Daniel
@Soare-Robert-Daniel I can't make it work, not sure if I'm missing anything. The values I save, disappear after a page refresh. I've tried with the free version of Otter from this PR https://vertis.d.pr/v/y6Bgy7 |
@HardeepAsrani, the FSE saving is now given by |
@Soare-Robert-Daniel Were you able to fix the issue Rodica has with this? |
Yes. |
@Soare-Robert-Daniel now everything's working well 👍 |
🎉 This PR is included in version 2.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #1802
Summary
[UPDATED]
A straightforward solution to this problem is to insert a dummy block and then delete it immediately. This will mark the block as dirty, thus enabling the Post/Page saving. The functionality is wrapped in a
debounce
function, which prevents multiple events from triggering simultaneously.ℹ️ This works reliably in Post/Pages/FSE/Widgets/Customizer 🔥
[OLD SOLUTION]
Usually, the Save button is enabled when you make a change to the content of the post/page. The problem arises when some functionality is not tied to the content but is triggered by the
Save
button.Form Options live in the WP Options. When a user changes something in the Form the Mail, the values must be saved in WP Options to take effect. They are not tied to the block attributes, thus making them invisible for the Editor to detect changes.
After some heavy investigation regarding the saving mechanism in the Gutenberg editor, a simple trick to enable the saving is to make a request using the function
dispatch( 'core' ).editEntityRecord
.In this PR, we implement a function that makes this request by adding an unregistered meta value to the entity. Since it is unregistered, the value is not saved anymore, but making the request marks the post/page as
dirty
, thus enabling theSave
button.Screenshots
2023-08-29.17-36-19.mp4
Test instructions
Save
button should be available.Save
will be available after 3 seconds without modification. As long as you type or change something in the Form options within 3 seconds, it will not trigger.Form options have been saved
, which confirms the save request.Checklist before the final review