Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add Patterns to Page in Zoom Out when all Page Content is removed #67564

Open
3 of 6 tasks
getdave opened this issue Dec 4, 2024 · 8 comments · May be fixed by #68028
Open
3 of 6 tasks

Cannot add Patterns to Page in Zoom Out when all Page Content is removed #67564

getdave opened this issue Dec 4, 2024 · 8 comments · May be fixed by #68028
Assignees
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@getdave
Copy link
Contributor

getdave commented Dec 4, 2024

Description

When a Page is completely empty of all content (including any default placeholder paragraph block) then it is impossible to add Patterns to a Page in Zoom Out.

Step-by-step reproduction instructions

  1. Site Editor -> Pages
  2. Edit a Page
  3. Remove all content from the Page (including the default paragraph). You should only have the core/post-content block left.
  4. Zoom Out
  5. See that you cannot add Patterns

Screenshots, screen recording, code snippet

Screen.Capture.on.2024-12-04.at.10-58-54.mp4

Environment info

  • Latest Gutenberg trunk
  • Chrome

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@getdave getdave added [Type] Bug An existing feature does not function as intended [Feature] Zoom Out labels Dec 4, 2024
@getdave
Copy link
Contributor Author

getdave commented Dec 4, 2024

cc @richtabor who discovered this bug

@Anuj-Rathore24
Copy link

I believe it is because there is no insertion point in an empty editor. As mentioned in the two pre-required conditions for pattern insertion in zoom out mode.

Reference -:

// We want to show the zoom out separator in either of these conditions:
// 1. If the inserter has an insertion index set
// 2. We are dragging a pattern over an insertion point

@getdave
Copy link
Contributor Author

getdave commented Dec 4, 2024

Thanks for looking that out 👍

The goal should be to always show some kind of insertion point so we need to amend that code.

@getdave
Copy link
Contributor Author

getdave commented Dec 5, 2024

We should also take a close look at this conditional which will stop the drop zone being rendered

const isSectionBlock =
rootClientId === sectionRootClientId &&
sectionClientIds &&
sectionClientIds.includes( clientId );
if ( ! isSectionBlock ) {
return null;
}

@getdave
Copy link
Contributor Author

getdave commented Dec 16, 2024

Looked into this some more. It turns out the core/post-content block is acting as a dropzone. However, it has no height and thus no drop events are triggered when dragging over it.

I tested by adding a min-height: 100px to the element and the drag and drop works as expected, even if there is no visual indication that this will be the case.

I believe this is because in non-zoomed out, the in between inserter (i.e. the thin blue line that appears) acts as an indicator for the dropzone.

@getdave
Copy link
Contributor Author

getdave commented Dec 16, 2024

A part fix is in #68026 which improves visual affordances when dragging over the unmodified default paragraph.

@getdave
Copy link
Contributor Author

getdave commented Dec 16, 2024

Further to the above the solution will likely be as follows:

  • add a min height to the post content block in Zoom Out - this allow for drag and drop operations to trigger.
  • render a Zoom Out Separator only in the main "entry content" if/when the block list is empty.

@draganescu
Copy link
Contributor

I am not sure this is a zoom out issue. One cannot drop blocks or patterns in the canvas if there is nowhere to drop them to. If the user managed to create a situation we should solve the problem globally and detect that situation, then decide on some heuristic (e.g. depending on the entity edited) to insert somewhere where it seems best.

Or we should let the user know there is nowhere to insert via some notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants