Fix editor dynamic width on WP 5.6 #1520
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1512.
First, I would like to summarize what this feature is about:
While this PR fixes the issue and (I think) cleans up a bit the code, I still fill this feature is very fragile. We are directly interacting with the DOM of the editor, so the code might break every time there is an update in the editor markup in a future WP update. In fact, that same code stopped working some months ago with WP 5.4 (see #1316).
I'm not sure if there is a better way to handle this with proper APIs, if there is, I couldn't find it but I would be happy to be corrected, so we could fix this issue in a robust way. In case there isn't any supported API, we have several options:
Thoughts @haszari @nerrad?
In addition to that, I opened an issue in Gutenberg repo with our use-case. You can find it here: WordPress/gutenberg#26494. We would also need WordPress/gutenberg#18571 to be fixed in order to be able to completely re-write this feature using supported APIs.
Screenshots
How to test the changes in this Pull Request:
Do the testing steps above with WP 5.5 and WP 5.6.
I also tested it with IE11 to ensure code is compatible with it.
Affected flows & features:
Changelog