Problem/Motivation
Since #2368797: Optimize ajaxPageState to keep Drupal 8 sites fast on high-latency networks, prevent CSS/JS aggregation from taking down sites and use HTTP GET for AJAX requests, the view preview does no longer attach assets (css/js) provided by plugins. This is due to early usage of drupal_render() in ViewUI::renderPreview(). Since assets are no longer added statically, renderPreview returns HTML which is added as markup to the ViewPreviewForm, and assets get lost.
Proposed resolution
Change ViewUI::renderPreview() to return a render array instead of HTML so that when the form is rendered, it also accounts for the nested '#attached' assets.
Remaining tasks
Review patch
User interface changes
None
API changes
ViewUI::renderPreview() returns a render array instead of HTML.
Beta phase evaluation
| Issue category | Bug because css is not being attached to the views preview. |
|---|---|
| Prioritized changes | The main goal of this issue is fixing a bug in VDC to improve D8 stability. |
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2412805_view-preview_4.patch | 4.89 KB | mondrake |
| #4 | 2412805_view-preview_4-test-only.patch | 2.4 KB | mondrake |
| #1 | 2412805_view-preview_1.patch | 2.48 KB | mondrake |
Comments
Comment #1
mondrakeComment #2
mondrakeComment #3
wim leersOh :( Missed that one despite much manual testing by myself and others. Tests would've prevented that.
Great catch; initial patch looks good.
EDIT: and thanks for commenting on the issue that caused this, that's how I found this :)
Comment #4
mondrakeAdded tests - used the
hook_views_preview_info_alter()implementation of the views_ui_test module to add a library.Test-only == interdiff.
Comment #6
joelpittetThis looks good to me, thanks for the tests @mondrake!
Comment #7
alexpottNice find and fix. Committed b3312d0 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.