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

Fix image layout shift from placeholder to selected placeholder #59857

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/block-library/src/image/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// @todo: this particular minimal style of placeholder could be componentized further.
.wp-block-image.wp-block-image {

&:not(.is-selected) .components-placeholder__fieldset {
// Show only is selected.
display: none;
}

// Show Placeholder style on-select.
&.is-selected .components-placeholder {
// Block UI appearance.
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/placeholder/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@

// By painting the borders here, we enable them to be replaced by the Border control.
@include placeholder-style();
overflow: auto;

overflow: hidden;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overflow hidden seems risky here as it could cause some controls to be inaccessible via the UI 🤔

Would it make sense to only apply overflow hidden when the block is not selected/reset it to auto when the block is selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are already hidden in the UI, this is not accessible in any way shape or form:

Screenshot 2024-03-14 at 09 48 22

This is why we've increasingly been careful about using the generic Placeholder pattern, and in fact why the Site Logo and Featured Image placeholders are patterns to follow for the best results, rather than the existing component. Those feature only a single button, acknowledging the fact that so long as you can insert a block into a colum that's 50x50px, they simply need to scale. There's a bit more discussion here: #58685 (comment)

I hear you though, there may be a larger refactor necessary of the image block component. Perhaps #59275 can lead the way?

Alternatively I'd recommend a revert of the original PR to fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in the screenshot you have there it is a very subpar experience. But technically (and I know because I had to fight this a few times already) you can still scroll the area and find what you are looking for.

I would love a refactor of this. But I think an immediate fix would be to only apply the

overflow: hidden when the block is not selected. That would still prevent the layout shift but still retain the ability to scroll this area here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love a refactor of this. But I think an immediate fix would be to only apply the overflow: hidden when the block is not selected. That would still prevent the layout shift but still retain the ability to scroll this area here

I have to temporarily move on to a separate thing, but good point, I can try this later. Otherwise if you're up for it feel free to push directly to the branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work, what do you think?

scrollbars only when selected

.is-selected & {
overflow: auto;
}
}

// Position the spinner.
Expand Down
Loading