Problem/Motivation

While working on #3594176: Slot handlers as island plugins, I am confused with the instance-id data attribute added by BuilderPanel, LayersPanel and PresetLibraryPanel:

'#attributes' => [
  'data-db-id' => $builder_id,
  'data-slot-id' => $slot_id,
  'data-slot-title' => \ucfirst($definition['title']),
  'data-node-id' => $instance_id,
  'data-instance-id' => $instance_id . '_' . $slot_id,
],

which has been added in March by https://git.drupalcode.org/project/display_builder/-/merge_requests/253/

Because it is never an Instance entity ID, and only sometimes and Tree Node ID (tree nodes were also previously called" instance"). Sometimes it is a tree node id, sometimes it is a preset entity ID, sometimes it is a combination of node ID and slot, sometimes it is an opaque string...

The current difficulties to pass the playwright tests in #3594176: Slot handlers as island plugins may be related to this confusion.

Proposed resolution

  1. Rename data-instance-id with data-test-id
  2. Add a comment explaining this attribute is related to https://playwright.dev/docs/locators#locate-by-test-id (I am not comfortable with markup added only for playwright tests, this is making the DOM busy, but this is not the topic of this ticket)
  3. Add missing data-node-id in BuilderPanel and LayersPanel

Also, if relevant, add the "Pass a full InstanceInterface between BuildePanel" part from #3594176: Slot handlers as island plugins.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

pdureau’s picture

Title: Rename adn document data-instance-id attribute » Rename and document data-instance-id attribute
pdureau’s picture

Issue summary: View changes

pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Active » Needs review

Ready for review. A warning in playwright_extra, i don't really know if it is blocking a MR or not.