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

Post Edit block invisible when using textColor: white and a default gradient #3

Open
bobbingwide opened this issue Jul 25, 2021 · 5 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@bobbingwide
Copy link
Owner

Post Edit block invisible on the front end when using textColor: white and a default gradient.

The following source can lead to the display of an invisible block. The gradient is not being rendered.

<!-- wp:oik-sb/sb-post-edit-block {"textColor":"white","gradient":"vivid-cyan-blue-to-vivid-purple"} /-->

This is strange because the gradient works for the the UK tides block!
Here's an example with the gradient set to Light green cyan to vivid green cyan for the first UK Tides block and the Post Edit block.
image
In the front end gradient is not being applied to the Post Edit block.
image

The generated outer div for the UK tides block is

<div class="has-text-color has-dark-gray-color has-background has-light-green-cyan-to-vivid-green-cyan-gradient-background wp-block-uk-tides-uk-tides has-medium-font-size">
rest of block output goes here
</div>

For the Post Edit block it's

<div class="wp-elements-60fd966435b20 wp-elements-60fd966435afa wp-block-oik-sb-sb-post-edit-block">
rest of block output goes here
</div>
@bobbingwide bobbingwide added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Jul 25, 2021
@bobbingwide bobbingwide self-assigned this Jul 25, 2021
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 25, 2021

The value of settings.color in the block.json file for the UK tides block is

 "color": {
          "gradients": true,
         "text": true,
         "background": true,
          "link": true
        },

For the Post Edit block I'd changed the settings from

"color": {
	  "gradients": true,
	  "link": true
	},

to the shortcut "color": true which enables background and text; gradients and link are disabled.

But I hadn't rebuilt the JavaScript, so in the editor the block still supported gradient and link.

I believe this explains the problem.

Solution

For the Post Edit block settings.color should be as for the UK tides block.

@bobbingwide
Copy link
Owner Author

That's better.
image

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 25, 2021

But...

image

You can actually see the top left corner of the gradient on the green one.
So, it doesn't matter if Link color is supported or not.
It's the SSR logic that's causing the gradient to be applied twice.

@bobbingwide
Copy link
Owner Author

It's the SSR logic that's causing the gradient to be applied twice.

I'd added this logic either to be able to style the Link using the Text colour, or to attempt to set the background of the Link not the outer div.

$extra_attributes['href'] = esc_url( $url );
$link_wrapper_attributes = get_block_wrapper_attributes( $extra_attributes );	

Either way, it doesn't quite work. It sets the class for the background gradient on the <a> tag as well as on the outer <div>.
Removing this logic works when the Link color is settable.

@bobbingwide
Copy link
Owner Author

In the Editor the block doesn't need the Text color settings.

bobbingwide added a commit that referenced this issue Jul 26, 2021
bobbingwide added a commit that referenced this issue Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant