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

Left- or right-aligning block-level elements leads to unexpected behaviour #8293

Closed
sarahmonster opened this issue Jul 30, 2018 · 9 comments
Closed
Labels
[Block] Image Affects the Image Block [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended

Comments

@sarahmonster
Copy link
Member

sarahmonster commented Jul 30, 2018

Describe the bug
Left- or right-aligning images leads to a whole host of issues:
2018-07-30 13 33 37

2018-07-30 14 25 20

  1. Left- and right-aligned images show the block toolbar above a (seemingly duplicated?) block inserter placeholder, whilst centre-aligned images show the toolbar closely attached to the block itself.
  2. When right-aligning, the toolbar floats to the right. This feels sort of intentional, but doesn't track with centre-aligned images (where it stays to the left) or with text alignments, which makes it feel a bit jarring.
  3. If you switch back and forth enough, eventually parts of the toolbar (the block switcher) just disappear entirely.
  4. Try clicking out of the image and then clicking back in—instead of selecting the image block, you end up selecting the block before/after it.

This seems to happen with all block-level elements that I've tested so far.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new post and add an image block.
  2. Switch its alignment around and see what happens.

Desktop (please complete the following information):

  • OS: Mac, Firefox Nightly
@sarahmonster sarahmonster added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks labels Jul 30, 2018
@kjellr kjellr mentioned this issue Jul 31, 2018
7 tasks
@kjellr
Copy link
Contributor

kjellr commented Jul 31, 2018

Here's a related bug:

  1. Add a cover image
  2. Set it to align to the left or right.
  3. Click outside of the image.
  4. Your cover image block disappears!

cover-image-alignment-disappear

@kjellr
Copy link
Contributor

kjellr commented Jul 31, 2018

Some of these are raised in #7500 too.

@sarahmonster
Copy link
Member Author

sarahmonster commented Aug 6, 2018

This issue is a bit more pronounced in the mobile view, where the entire toolbar actually switches position upon changing the alignment:

https://www.dropbox.com/s/yojv1al9l1j27wg/float-issue.mov?dl=0

@cbirdsong
Copy link

This happens with more than just images:

screen shot 2018-08-07 at 10 20 58 am

@ZebulanStanphill
Copy link
Member

@cbirdsong Isn't that technically the correct behavior? It is kind of annoying in some cases, but that is kind of how floats work. Of course, it would be ideal if you could make a block clear floats above it, but there has not been any solution decided upon to make that happen: #4127.

@cbirdsong
Copy link

@ZebulanStanphill It is, but I am not sure passing the confusing way CSS floats work along to the user is helpful, especially since there isn't (and shouldn't be) a clearfix block. This is all compounded by how difficult it can be to track down the right set of floating toolbar icons that control alignment, as mentioned in #7500 and other places.

@ZebulanStanphill
Copy link
Member

@cbirdsong It is stuff like this that makes me think that perhaps Gutenberg should go the direction of #4314 and use CSS Grid as the default layout method, relegating float alignment to only being available in containers set to display: block, which could be done with some kind of container block with layout settings to switch between grid, flex, and block CSS layout modes... perhaps the Container block proposed in #4900.

@sarahmonster sarahmonster changed the title Left- or right-aligning images leads to unexpected behaviour Left- or right-aligning block-level elements leads to unexpected behaviour Aug 14, 2018
@sarahmonster sarahmonster mentioned this issue Aug 14, 2018
10 tasks
@sarahmonster sarahmonster added the [Block] Image Affects the Image Block label Oct 25, 2018
@youknowriad
Copy link
Contributor

Is this issue still relevant? I feel like we've done all what we can do to improve the floats (which are not a great thing in general but we can't afford to remove). cc @jasmussen

@jasmussen
Copy link
Contributor

I would agree that we have made enormous strides in improving the situation here. I believe all the GIFs in this thread are addressed. For that reason, I'm closing it. But it's also easy to reopen, or create new specific tickets, if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

6 participants