-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Rendering legacy widgets preview via an iframe may lead to a 414 URI too long error #33540
Comments
One way to solve it would involve switching to POST requests and "manually" populating the preview iframe. |
I started exploring a solution in WordPress/wordpress-develop#1508 |
This ties into "Investigate alternatives to using an iframe in Legacy Widget block" on #33242. I was wondering if we could look at using |
@noisysocks I actually had a working prototype of |
The API request PR is not a draft anymore: WordPress/wordpress-develop#1508 @noisysocks would you mind reviewing? |
I might be missing some context here, but switching to POST request alone doesn't seem to be enough? We're still depending on iframes to render the previews in isolation, and AFAIK, iframe can't load a POST request url. We'll need something else to use JavaScript to render the response from that POST request. Is there any plan about that? @noisysocks's portal and shadow DOM approaches seem promising. Might want to prove that they work before merging the POST api PR. |
@kevin940726 you can perform the POST request via |
Oh I see, we can use srcdoc for that, I totally forgot about that! The only difference might only be the lack of url, but I think it should be fine in our case. |
While we're fiddling around in here, let's add better error handling to this |
Description
Legacy widgets are rendered using an
<iframe />
withsrc
set like this:gutenberg/packages/widgets/src/blocks/legacy-widget/edit/preview.js
Lines 99 to 104 in fea614a
This works when there aren't many parameters or when the server tolerates very long query strings. Unfortunately, when one of these conditions isn't met, we may see an error 414 URI too long like on the screenshot below:
This is easiest to reproduce with a long piece of text, but it also occurs with short inputs when certain plugins are installed. For example, the https://pl.wordpress.org/plugins/widget-visibility-time-scheduler/ adds a number of form fields to every legacy widget's form and triggers errors 414 in certain configurations.
Step-by-step reproduction instructions
Expected behaviour
A correctly rendered preview
Actual behaviour
Error 414 (if there isn't one, just add a few more paragraphs of text and try again)
The text was updated successfully, but these errors were encountered: