This is now merged!

Demo!

Live demo of focus mode

Overview

Introduce "focus mode" for global regions that allows users to work with components inside the focused region. Regions other than Content should be inactive for component placement or selection unless they're focused.

Proposed resolution

  • Double-clicking the region name in the layers menu should enter focus mode;
  • Exiting focus mode should happen via the breadcrumb-like label in the center of the header;
  • The app routing (URL) should reflect the currently focused region — with Content being the default.

User interface changes

🎨 Design in Figma

Focus mode design

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

balintbrews created an issue. See original summary.

balintbrews’s picture

We'll need a UI component (or set of components) to display the name of the currently focused region in the top bar, and allow exiting from focus via clicking it. This will need to be coordinated with the work in #3489106: Show page information in top bar.

wim leers’s picture

Once #3497747: Global regions containing only "dynamically missing blocks" (due to emptiness or access) cause malformed pages is fixed, this issue will probably have to trigger the use of \Drupal\Core\Plugin\PreviewAwarePluginInterface — because some blocks only render at all in specific contexts — for example: the messages block is only visible at all when there's actual messages.

See \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray::onBuildRender() (see also how that uses \Drupal\Core\Render\PreviewFallbackInterface), introduced in #3027653: Allow block and layout plugins to determine if they are being previewed and CR at https://www.drupal.org/node/3272267. Note that this will also require core changes, because not all crucial block plugins implement that interface, which is why #3137995: Can't manage Status Messages block in Layout Builder still exists.

This also relates to #3491701: [later phase] ApiLayoutController must use the previewed route's controller, and override canonical content entity routes' received entity object, because without that, the preview will not be accurate. Hopefully we can do that at a later time, though.

balintbrews’s picture

Wim, this is all extremely valuable to be aware of, thank you! I wonder, though, if we could keep this issue smaller and only focus on the UX and UI aspects of focusing the regions. We have all the pieces in place to make that happen in a smaller scope — in favor of progress. What do you think?

Also, what are we missing in terms of design? I linked to the relevant part of the Figma project, and also added a screenshot.

wim leers’s picture

Title: [Needs design] Focus mode for global regions » Focus mode for global regions
Issue tags: -Needs issue summary update, -Needs design +Needs followup

Okay, I'll extract #3 into a separate issue.

The designs do not provide answers for the highly dynamic Block-sourced Components: it assumes all component instances in the Layers panel are always visible. That's not true for many Block plugins:

  • messages block
  • local tasks block
  • local actions block

But I'm fine with this issue focusing on that tighter scope.

balintbrews’s picture

The designs do not provide answers for the highly dynamic Block-sourced Components: it assumes all component instances in the Layers panel are always visible.

Okay, that definitely does need design in the follow-up issue. 🙂 Thanks for agreeing to that.

wim leers’s picture

wim leers’s picture

wim leers’s picture

Title: Focus mode for global regions » [PP-1] Focus mode for global regions
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

Per #2, this is blocked on #3489106: Show page information in top bar, right @balintbrews?

balintbrews’s picture

Title: [PP-1] Focus mode for global regions » Focus mode for global regions
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs issue summary update

It's not blocked, but at one point some coordination may be required. 😊

wim leers’s picture

Would this issue benefit from automated tests, or would that be disproportionately complex and would this benefit from (documented) manual testing instead?

balintbrews’s picture

Assigned: balintbrews » jessebaker
wim leers’s picture

jessebaker made their first commit to this issue’s fork.

effulgentsia’s picture

Issue tags: +sprint

Up until now, the XB team has been following a pseudo-scrum/pseudo-kanban process, but we're now shifting into more conventional scrum. We started a new 2-week sprint last Thursday (Jan 16). I'm tagging our current sprint's issues for visibility.

wim leers’s picture

Issue tags: +Needs screenshots

This is well on its way, but not yet ready for review. The demo I saw @jessebaker do in private is 🤩, and a demo of the end result should definitely be made available here too! 😄

larowlan’s picture

Status: Active » Needs work
StatusFileSize
new34.43 KB
new408.22 KB

In my manual testing the highlight is slightly off for the header

Also it doesn't look like form state values are getting emptied when the component is changed

You can see here form state for two different components, not just the selected one

larowlan’s picture

#3501870: Block form state not cleared when component is changed adds test coverage for the form state slice and confirms the clearing of component values is working in HEAD

bnjmnm made their first commit to this issue’s fork.

lauriii’s picture

Tested this manually and noticed few things:

  1. Double clicking the region in the preview does not open the focus mode which is the first bullet in the proposed resolution
  2. The breadcrumb in the header is now duplicated 🤔
  3. We should take margin into account when determining the position of the highlight:
jessebaker’s picture

StatusFileSize
new263.78 KB

RE: #22

1. Resolved. I've also made it so that double clicking the focused region in the layers will take you back out again so you don't have to move your mouse all the way up to the top nav to move between regions.

2. Looks like the Page nav got merged in after this was ready for review. I've correctly reconciled that - and fixed the size of the Page drop down to match Figma while I was here!

3. The margin/size of the region is taken into account. The issue you are showing in your screenshot is that the breadcrumb block has CSS with negative margins to make it appear outside of the region it is rendered in. I'm not sure I can think of a solution for that?

jessebaker’s picture

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

hooroomoo made their first commit to this issue’s fork.

hooroomoo’s picture

I just pushed a one line css commit for the cursor.

Before:

After:

lauriii’s picture

Issue summary: View changes
StatusFileSize
new988.4 KB

#9 is still unaddressed.

With #22.1, I was referring to this flow where you should be able to hover over a region in the preview and access the focus mode from there:
. It seems that there's already a lot being changed here, so we could potentially move this to a follow-up issue.

jessebaker’s picture

I'm going to merge this and then create follow ups to address the outstanding issues. The MR is too unwieldy to keep alive due to the size of it! Watch this space for new issues.

wim leers’s picture

Assigned: Unassigned » jessebaker
Status: Fixed » Needs work

#30: which of those belong in #3455753: Milestone 0.2.0: Early preview and which are must/should/nice-to-have?

Finally: could you please upload a screencast showcasing this awesomeness so I can blog about it? 🤓🙏

jessebaker’s picture

Issue summary: View changes
Issue tags: -Needs screenshots
StatusFileSize
new5.05 MB
new3.33 MB
jessebaker’s picture

Assigned: jessebaker » Unassigned
Status: Needs work » Fixed

I have ranked the follow ups and added them to #3455753: Milestone 0.2.0: Early preview to be tracked and added a gif of the new functionality to the summary.

effulgentsia’s picture

Issue tags: -sprint
wim leers’s picture

🤩

Status: Fixed » Closed (fixed)

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