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 gallery not displaying correctly when aligning right or left. #3299

Merged
merged 1 commit into from
Nov 8, 2017

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Nov 1, 2017

This two lines PR aims to address an issue raised in #2690. The problem is that some themes overwrite the display property. The problem happens in right and left alignment, not in center. The technique already being used to increase selector specificity for center alignment was also applied for left and right. With this simple change, it looks like the problem got fixed.
Please that in the editor things look nice the problem only happens when seeing the post. It is possible to see the problem happening in the screen below where the gallery was set to two columns and the setting was not respected.

The container may still take all the space and we may not be able to notice the difference between the center and right/left alignments. But this is common in many other blocks e.g: image block. And for now, it looks like the expected behavior from blocks when the width is big.

Before

screen shot 2017-11-01 at 20 40 39

After

screen shot 2017-11-01 at 20 40 11

@jorgefilipecosta jorgefilipecosta self-assigned this Nov 1, 2017
@jorgefilipecosta jorgefilipecosta added [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended labels Nov 1, 2017
@jasmussen
Copy link
Contributor

Tested and I see the same result as you show in your screenshots. Which, so far so good!

But the point you bring up makes sense, it is a little weird that the left aligned gallery in the editor is not full width, but the saved version is:

screen shot 2017-11-02 at 08 20 52

screen shot 2017-11-02 at 08 20 58

Should we be more opinionated here, and let the width bleed through to the frontend?

@jorgefilipecosta
Copy link
Member Author

Should we be more opinionated here, and let the width bleed through to the frontend?

Hi @jasmussen, my option is that yes we should consider having rules that set the width, so things look similar when published. And given that we expect that a block in the future may be added for example to sidebars where it may not make sense to set the width like in the content area. I would solve the problem by adding a rule that only applies to the content e.g. .content-area .wp-block... {.
Another approach possible may be having a very common slider to set the width in % so we leave that decision to the content creators.

@jasmussen
Copy link
Contributor

@mtias has suggested a add_theme_support clause for Gutenberg styles, for example for the basic blockquote styles, so you can opt in to allowing Gutenberg to override your theme styles (or supply a baseline). In this case I'm suggesting that the baseline for a floated gallery should be the same on the backend as in the frontend.

Perhaps not necessary to address in this PR, but it does bring up the issue of inconsistencies between front and backend.

@jorgefilipecosta
Copy link
Member Author

jorgefilipecosta commented Nov 2, 2017

We can never guarantee that the results will be the same, themes may always have rules with higher specificity that overwrite ours, but for left and right alignment widths we have max-width: 370px; rule on the editor that makes things look at +- 50% width and on the post itself we don't have a rule at all. It's something to consider, but not directly in the scope of this pr, as the width problem is general to most blocks.

@jorgefilipecosta
Copy link
Member Author

Hi @jasmussen, do you think it is ok to merge this small fix?

@jasmussen
Copy link
Contributor

Sure. We need to look at frontend styles in a more cohesive way soon anyway.

The problem is that some themes overwrite the display property. The technique already being used to increase selector specificity for center alignment was also applied for left and right.
@jorgefilipecosta jorgefilipecosta force-pushed the update/fix-gallery-align-right-left branch from 32ffbb0 to 3125387 Compare November 8, 2017 16:15
@jorgefilipecosta jorgefilipecosta merged commit b0f9bb6 into master Nov 8, 2017
@jorgefilipecosta jorgefilipecosta deleted the update/fix-gallery-align-right-left branch November 8, 2017 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants