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

Bug: wrong class name has-background-dim-0 with opacity 0.5 #27495

Closed
vHeemstra opened this issue Dec 4, 2020 · 1 comment
Closed

Bug: wrong class name has-background-dim-0 with opacity 0.5 #27495

vHeemstra opened this issue Dec 4, 2020 · 1 comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@vHeemstra
Copy link

vHeemstra commented Dec 4, 2020

Description
When you set the transparency on a cover block to 1 through 4 in the editor, this will be rounded to 0 but is not ignored by the ! ratio check. So it ends up with a class name of has-background-dim-0 which has no styling, but defaults to opacity 0.5 because of the .wp-block-cover__gradient-background class default opacity. This happens in the editor WYSIWYG as well as on the front-end.

Possible solution 1

export function dimRatioToClass( ratio ) {
return ratio === 0 || ratio === 50 || ! ratio
? null
: 'has-background-dim-' + 10 * Math.round( ratio / 10 );
}

Let line #59 also check on the rounded opacity value by adding || 0 === Math.round( ratio / 10 ) or similar.

Possible solution 2

@for $i from 1 through 10 {
&.has-background-dim.has-background-dim-#{ $i * 10 } {
&:not(.has-background-gradient)::before,
.wp-block-cover__gradient-background {
opacity: $i * 0.1;
}
}
}

Have the SCSS file include a has-background-dim-0 class definition with opacity: 0 by starting the @for on 0.

NB:
I'm not sure if this the only place where this bug occurs. (Not that familiar with the code base ;) )

@ntsekouras ntsekouras added [Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Bug An existing feature does not function as intended Good First Issue An issue that's suitable for someone looking to contribute for the first time labels Dec 4, 2020
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 8, 2020
@ramonjd
Copy link
Member

ramonjd commented Feb 15, 2022

I can't reproduce this. I think it might have been addressed by #35065 or an earlier PR.

Feel free to reopen if the problem persists. Thank you!

@ramonjd ramonjd closed this as completed Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image Good First Issue An issue that's suitable for someone looking to contribute for the first time [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