Add block restriction validation at start of drag

Created on 24 August 2022, over 2 years ago
Updated 29 July 2024, 5 months ago

Problem/Motivation

Currently the editor has to wait until the block is dropped before being alerted to restrictions. This user experience is less than ideal and leaves the user guessing as to where they can safely move a block.

Proposed resolution

Create a controller to handle immediate validation instead of waiting for the block move end. Use ajax to update the layout without requiring the entire layout to be rebuilt.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs review

Version

3.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States michaellander

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States michaellander
  • Status changed to Needs work 11 months ago
  • Reviewing in Drupal 10, I'm unable to reorder any blocks in layout via dragging. I can still drag the element, but the yellow "destination" preview never moves from the original position. This occurs just by having the module enabled, even if no restrictions have been applied.

    I am able to reorder blocks if I select the "move" option on an individual block within the layout. Reordering itself seems unaffected - the drag and drop interface seems to be where the failure occurs.

    No dblog or console errors were generated.

  • Status changed to Needs review 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States michaellander

    Hi @bjc2265, I've tested this again and it's still working for me. Have you seen any error messages in console or drupal logs? I will say that if you have a lot of debugging turned on, or caching turned off, it may be a little slow(as with all things layout builder). Right now the default behavior is to prevent dropping anywhere until validation is done. I could always change it to allow dropping anywhere until validation is finished, which would fall back to the currently build-in validation. With normal cache settings enabled, it has been pretty seamless for me but I want to make sure that's true for others.

  • πŸ‡ΊπŸ‡ΈUnited States michaellander

    I really think this would be a nice addition to this module, and I would be happy to make it something that is an optional setting if we think it's too big of a change to introduce by default. Would love some feedback from a maintainer. Thank you!

  • πŸ‡ΊπŸ‡ΈUnited States brayn7 Lexington, Ky

    brayn7 β†’ changed the visibility of the branch 3305640-add-block-restriction to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States brayn7 Lexington, Ky

    brayn7 β†’ changed the visibility of the branch 3305640-add-block-restriction to active.

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson
  • πŸ‡ΊπŸ‡ΈUnited States daddison

    Hi @michaellander. Can you clarify the test scenario for this improvement? Does the layout_builder_restrictions_by_region submodule need to be enabled?

  • πŸ‡ΊπŸ‡ΈUnited States michaellander

    @daddison, good question. I believe I wrote it with layout_builder_restrictions_by_region enabled, but I don't believe it is required. It should just be respecting whatever the scope of permissions(section vs region) you have configured. The test scenario will be that the region won't even highlight for you to drop a block in unless it's allowed, instead of waiting for you to drop the block and then get the pop-up warning. If you are testing locally, and have cache turned off, along with a lot of dev tools enabled, it may be kind of slow to validate. Though we've been using it in production on a handful of sites and thus far the performance lag has been negligible.

Production build 0.71.5 2024