fix: #3615665 Page data panel is never hidden in the Canvas editor
Fixes #3615665: Page data panel is never hidden in the Canvas editor
Problem
hook_js_settings_alter() set drupalSettings.canvas.hidePageDataPanel by reading the entity from route parameters. Drupal Canvas serves its editor shell through a route match that carries no entity_type/entity parameters, so the guard always returned early and the flag was never set. Even when it was set, nothing consumed it: the code that read hidePageDataPanel lived in Drupal Canvas's front-end sources, and Canvas ships its editor as a prebuilt bundle, so a front-end patch could never survive composer install.
Fix
- Route-parameter guard replaced with request-path resolution.
canvasEditorNode()resolves the node from the/canvas/editor/node/{nid}request path, falling back to route parameters when Drupal does upcast them. - Editor behaviour shipped as this module's own library. A new
canvas_override/editorlibrary (JS + CSS) is attached to the Canvas editor viahook_library_info_alter(), appending it tocanvas/canvas-ui's dependencies. It loads with the editor without patching Drupal Canvas, and survivescomposer installand Canvas upgrades. The behaviour hides the Page data tab and moves selection to the next available tab when it is active, using aMutationObserverbecause the editor re-renders as the user works.
Verification
Performed on Drupal 11.4.5 with Drupal Canvas 1.10.0 (patched only for the ComponentTreeLoader extension point):
drupalSettings.canvas.hidePageDataPanelis nowtrueon a Canvas Override node editor, and correctly absent on/canvas.- The library loads: the module's JS and CSS are both present on the editor page and
Drupal.behaviors.canvasOverrideEditoris defined. canvas-uilistscanvas_override/editorin its dependencies.- With simulated editor tabs, the Page data trigger receives the
hiddenattribute, thecanvas-override-hiddenclass and computeddisplay: none, while sibling tabs stay visible. - The editor boots with zero console errors and
/canvas/api/v0/layout/node/{nid}returns HTTP 200 JSON. php -lclean; the hook service resolves and thecanvas_override/editorlibrary registers.
AI-Generated: Yes
Checkpoints:
- File an issue
- Addition/Change/Update/Fix
- Testing to ensure no regression
- Automated unit testing coverage
- Automated functional testing coverage
- UX/UI designer responsibilities
- Readability
- Accessibility
- Performance
- Security
- Developer Documentation
- User Guide Documentation
- Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release
Edited by Rajab Natshah