-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[edit-widgets beta] Fix legacy widgets preview #24861
Conversation
8a73ecb
to
92463cd
Compare
Size Change: +195 B (0%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
@@ -5,6 +5,9 @@ | |||
"widgetClass": { | |||
"type": "string" | |||
}, | |||
"id": { |
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.
I just removed this attribute in another PR, but without it there's no way to send it over through ServerSideRender
. In short - we need to have this attribute, but we shouldn't use it :-) A much better solution would be making the server side rendering API less restrictive - custom arguments would be incredibly helpful (and a great follow-up to this PR).
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.
Can we rename it "widgetId" or something like that. "id" is too generic and can potentially be used for something else that works across blocks like HTML ids. or block ids...
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.
Trying to test this I the error below when trying to add a legacy widget on this branch:
Looking in console the error is:
Uncaught Error: An error occurred while running 'mapSelect': widget is undefined
And the request to index.php?rest_route=%2Fwp%2Fv2%2Ftypes%2Fwidget-areas&context=edit&_locale=user
returns 404
Heads up I merged #24855 so this might need a rebase. I hope the above is just my env :O)
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.
Approach looks good but I can't test as am also getting the error mentioned above 🙂
@@ -273,6 +273,60 @@ public function test_get_items_active_sidebar_with_widgets() { | |||
); | |||
} | |||
|
|||
/** | |||
* |
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.
Write something here.
@@ -28,6 +28,13 @@ export const getWidgets = createRegistrySelector( ( select ) => () => { | |||
); | |||
} ); | |||
|
|||
export const getWidget = createRegistrySelector( |
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.
Add a doc comment.
92463cd
to
3e7f0c4
Compare
I rebased, added a few more changes, and it should work fine now.
It turns out one of the other PRs broke it on master :( This PR now fixes that problem. |
attributes={ omit( attributes, 'id' ) } | ||
attributes={ { | ||
widgetId, | ||
...omit( attributes, 'id' ), |
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.
should this be omit id or widgetid?
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.
This is definitely behaving better than master that said I'm still seeing two issues (potentially separate):
- When loading a legacy widget block (using the markee example), the placeholder of the legacy widget block is shown instead of the markee one directly.
- When I make edits and click "preview", the previously saved values are used but not the values I just typed.
Description
Fixes the problem where previewing an old-style widget in the Block Areas screen results in "Block rendered as empty".
Note that this PR is based on #24855.
How has this been tested?
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: