Problem/Motivation

First drawer (the one with some View panels triggered by buttons)

There is no label currently, this is leaving a weird blank space, so it would be nice to print the active panel title.

Second drawer (the one with Contextual panels triggered by instance loading)

While working on #3529049: Replace sidebars modals by drawers we removed InstanceButtons island (machine name: instance) because it was not necessary anymore.

However, we have lost the information about the current instance we are editing. We have a "Settings" title instead:

Proposed resolution

First drawer (the one with some View panels triggered by buttons)

Do we need to add event synchronize the value of the active button in .db-toolbar__start with the Drawer's label attribute?

Second drawer (the one with Contextual panels triggered by instance loading)

So, we need to find a way of updating title displaying SlotSourceProxy::getLabel() and reacting to:

  public function onActive(string $builder_id, array $data): array {
    return $this->reloadWithLocalData($builder_id, $data);
  }
  public function onDelete(string $builder_id, string $parent_id): array {
    return $this->reloadWithLocalData($builder_id, []);
  }

Or which is displaying SlotSourceProxy::getLabelWithSummary() (once #3529070: [1.0.0-alpha1] Use PluginSettingsInterface::settingsSummary()) and also reacting to:

  public function onUpdate(string $builder_id, array $data): array {
    return $this->reloadWithLocalData($builder_id, $data);
  }

The main difficulty is shoelace drawer's label to be a prop (WebComponent attribute instead of a slot. Because of that, we can't add an HTML ID to drawer's label specifically and target it with an out-of-band swap.

Maybe we can place this dynamic title elsewhere and add a JS event to sync with Shoelace Drawer's label attribute?

Other tasks

This may be the opportunity to do a few related tasks:

  • the drawers currently have HTML ID which may be conflicting because they don't use Builder ID: id="db-first-drawer" and id="db-second-drawer"
  • in drawer.js, is trigger.addEventListener('click', handleDrawer); is sometimes triggered? Is it useless?
CommentFileSizeAuthor
#19 Selection_153.png56.05 KBsea2709
db-drawer-settings.png12.13 KBpdureau
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

Issue summary: View changes
mogtofu33’s picture

goz’s picture

It's not so easy.

The twig is called when the display builder is loaded. Contextual islands are not loaded yet,and no contextual island plugin is loaded.
Islands Plugins are loaded once an instance is triggered, but only plugins are updated, not the contextual area.

Events seem to be triggered on islands plugins, not on the contextual area.

I look forward, but may be someone with more knowledge about how display_builder works has an idea ?

pdureau’s picture

Title: [1.0.0-alpha1] Replace "Settings" by an InstanceTitle island » [1.0.0-alpha2] Replace "Settings" by an InstanceTitle island

yes, it is not an easy task. Your analysis is right, Goz. Let's postpone it to alpha2.

pdureau’s picture

pdureau’s picture

Title: [1.0.0-alpha2] Replace "Settings" by an InstanceTitle island » Replace "Settings" by an InstanceTitle island
Assigned: Unassigned » pdureau
pdureau’s picture

Title: Replace "Settings" by an InstanceTitle island » Dynamic drawer labels
Issue summary: View changes
pdureau’s picture

Assigned: pdureau » Unassigned

I did the analysis and updated the issue description. Who takes the task?

mogtofu33’s picture

An other alternative is to do this on js as we have on the click element the html attributes of title and even index.
As the drawer title is a property set on the load of the component in the display_builder component it would avoir more php.

pdureau’s picture

pdureau’s picture

We are closing alpha4 soon

pdureau’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

I will give this a try

pdureau’s picture

Assigned: pdureau » Unassigned
sea2709’s picture

Assigned: Unassigned » sea2709
pdureau’s picture

sea2709’s picture

StatusFileSize
new56.05 KB

@pdureau:

When you have some time, can you review my MR? I found an issue when an instance for a entity field is active and the second drawer is open, then I change the field and click on Update, I expect the drawer label should be updated, but it's not.
screenshot

I found this piece of code in DisplayBuilderEventSubscriber

if ($island_id === $event->getCurrentIslandId()) {
        continue;
}

If I comment out this piece of code, the drawer label is updated correctly. I think when the instance form is update, the panel should be swapped.

sea2709 changed the visibility of the branch 3531253-dynamic-drawer-labels to hidden.

sea2709’s picture

Status: Active » Needs review
pdureau’s picture

Assigned: sea2709 » pdureau

I am having a first look

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

(This is a feature review, not a technical review)

Start (left in LTR layouts) sidebar

OK

End (right in LTR layouts) sidebar (contextuals panels)

I have a token block in a alert component in a grid component. From Layers panel:

  • I click on token: ❌ I see the instance form of token with the title of the grid
  • I click on token again: ✅ I see the instance form of token with the title of the token
  • I change the value on token form: ❌ the title switch back to the grid one

Same for alert component:

  • I click on alert: ❌ I see the instance form of alert with the title of the grid
  • I click on alert: again: ✅ I see the form of alert with the title of the alert
  • I change a value on alert form: ❌ the title switch back to the grid one
mogtofu33’s picture

Thanks for the work on that, as I mentioned on comment #10, if possible I would prefer to investigate a full js solution. Perhaps it's not possible but I see a lot of effort here and I don't want to have it wasted at the end.

sea2709’s picture

Assigned: Unassigned » sea2709

sea2709 changed the visibility of the branch 3531253-dynamic-drawer-labels-3 to hidden.

sea2709’s picture

Assigned: sea2709 » Unassigned
Status: Needs work » Needs review

Thanks @mogtofu33 and @pdureau,
When you have a chance, can you give it another around of review?

pdureau’s picture

Assigned: Unassigned » pdureau

I will do the functional review and let's Jean do the technical one

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

Nearly OK, thanks a lot for the progress.

Start (left in LTR layouts) sidebar

Still OK

End (right in LTR layouts) sidebar (contextuals panels)

I have a token block in a alert component in a grid component. From Layers panel:

  • I click on token: ✅ I see the instance form of token with "Token" as title
  • I click on token again: ✅ I see the instance form of token with "Token" as title
  • I change the value on token form: ✅ I see the instance form of token with "Token" as title

Same for alert component:

  • I click on alert: ✅ I see the instance form of alert with the "Alert" as title
  • I click on alert: again: ✅ I see the instance form of alert with the "Alert" as title
  • I change a value on alert form: ✅ I see the instance form of alert with the "Alert" as title

However:

  • I drop a new component to the builder panel: ❌ I see "Component" instead of the name off the component
mogtofu33’s picture

I didn't have time to check the code, but when I am proposing more js side, note that it's because we already have the component name in the DOM, it's the attribute `data-node-title`. I am using it to display the current component name in the right click menu. So I guess we could achieve the same for the end drawer.

sea2709’s picture

Assigned: Unassigned » sea2709

mogtofu33’s picture

Fixing the second drawer opening I realize with your secondDrawer.label = I could simply set the title.
For first sidebar as well, pretty easy to set the button label.
The difficult part was on drag, but I managed it in js as well.

Opening a branch for this js only, thanks for the work @sea2709.

mogtofu33’s picture

Assigned: sea2709 » Unassigned
Status: Needs work » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • mogtofu33 committed 55d33579 on 1.0.x
    [#3531253] feat: Dynamic drawer labels
    
    By: mogtofu33
    By: sea2709
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.