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

  1. 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.
  2. Editor behaviour shipped as this module's own library. A new canvas_override/editor library (JS + CSS) is attached to the Canvas editor via hook_library_info_alter(), appending it to canvas/canvas-ui's dependencies. It loads with the editor without patching Drupal Canvas, and survives composer install and Canvas upgrades. The behaviour hides the Page data tab and moves selection to the next available tab when it is active, using a MutationObserver because 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.hidePageDataPanel is now true on 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.canvasOverrideEditor is defined.
  • canvas-ui lists canvas_override/editor in its dependencies.
  • With simulated editor tabs, the Page data trigger receives the hidden attribute, the canvas-override-hidden class and computed display: 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 -l clean; the hook service resolves and the canvas_override/editor library 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

Merge request reports

Loading