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

Paragraph placeholder in InnerBlocks is set to opacity 0 #35928

Closed
virgiliud opened this issue Oct 25, 2021 · 4 comments · Fixed by #42519
Closed

Paragraph placeholder in InnerBlocks is set to opacity 0 #35928

virgiliud opened this issue Oct 25, 2021 · 4 comments · Fixed by #42519
Assignees
Labels
[Block] Paragraph Affects the Paragraph Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@virgiliud
Copy link

virgiliud commented Oct 25, 2021

Description

When generating an InnerBlock with a template in the editor, the placeholder of a paragraph that's immediately after another paragraph is set to opacity 0. Please see screenshot.

Step-by-step reproduction instructions

  1. Create an InnerBlock with the following allowed blocks and template:
const ALLOWED_BLOCKS = [ 'core/image', 'core/paragraph', 'core/list', 'core/group', 'core/heading', 'core/button' ];

const TEMPLATE = [
  [ 'core/heading', { placeholder: 'Price Title' } ],
  [ 'core/paragraph', { fontSize: 'large', placeholder: '$49/mo' } ],
  [ 'core/paragraph', { placeholder: 'Price Subtitle' } ],
  [ 'core/list', { placeholder: 'Feature list' } ],
  [ 'core/button' ]
];
  1. Generate the InnerBlock in the edit() function with the following settings:
<InnerBlocks
      allowedBlocks={ ALLOWED_BLOCKS }
       template={ TEMPLATE }
       renderAppender={ InnerBlocks.ButtonBlockAppender }
/>
  1. In the editor, the paragraph block with the placeholder "Price Subtitle" will have 0 opacity.

Screenshots, screen recording, code snippet

image

Environment info

WP version 5.8.1, using the stable Gutenberg version (not the plugin with experimental features)
Tested in multiple themes

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@stevenlinx stevenlinx added the Needs Testing Needs further testing to be confirmed. label Oct 27, 2021
@skorasaurus skorasaurus added [Type] Bug An existing feature does not function as intended CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Block] Paragraph Affects the Paragraph Block and removed Needs Testing Needs further testing to be confirmed. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Nov 22, 2021
@skorasaurus
Copy link
Member

That is an odd error; I am able to reproduce this on Gutenberg trunk last built on 2021-11-18;

Investigating this more; the cause is this CSS in the paragraph bloc.

@jasmussen - could you shed some light for this decision?

@jasmussen
Copy link
Contributor

Sure! It was added in #28275 to fix #13599. That is, if you create 10 empty paragraphs in a row, there's little value in seeing Type / to choose a block repeated ten times.

A very ugly hack we can't ship would be to do this:

.block-editor-block-list__block[data-empty="true"] + .block-editor-block-list__block[data-empty="true"] {
	[data-rich-text-placeholder="Type / to choose a block"] {
		opacity: 0;
	}
}

Screenshot 2021-11-23 at 09 24 55

Should we add an additional data-custom-placeholder attribute that just ensures full opacity?

@ndiego
Copy link
Member

ndiego commented Jul 19, 2022

I just encountered this issue on a project I am working on. @jasmussen I like the idea of data-custom-placeholder attribute that can easily be targeted with CSS.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 19, 2022
@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jul 26, 2022
@afercia
Copy link
Contributor

afercia commented Jul 26, 2022

I've been pinged on the associated PR and discovered this issue. Learned something new as I was unaware of this behavior.

I'm not sure the original change from #28275 / #13599 is a good choice in the first place. In my opinion, that introduced an accessibility and usability issue. The point is that the Editor is an editing interface. It should show what is editable. Instead, by hiding the default placeholder for the subsequent paragraph blocks, there's no visual indication of the editable fields.

No border, no shape, no placeholder text, nothing. Seems to me that deliberately hiding the editable parts of an interface is less than ideal. Consider the screenshot below, where:

  • A Row block contains 3 empty paragraphs, horizontally stacked.
  • After the Row, there are 6 empty paragraphs, vertically stacked.

no visible editable fields

As a user, I can't really see where the editable paragraphs are, with the exception of the first ones.

It's not even clear where I'm supposed to click to target the editable empty paragraphs. Hovering with the mouse doesn't help.

Basically, the interface is lying to users because there's really no visual presentation of the editable parts.

I'd like to stress that this is an editing context. While I understand the desire to make the editor a visual preview that is as close as possible to the front end, I'm not sure this is the right direction to take.

Overall, I'd like to propose to reconsider the original change and just revert it.

Minor, but interesting annoyance: when entering text or emptying the paragraphs, the placeholder visually 'moves' to the right / left and down / up. Basically, the placeholder appears and disappears based on the associated CSS rule that hides all subsequent placeholders (except the first one). The resulting visual effect is pretty confusing. I doubt users will actually understand why the placeholder appears and disappears. See animated GIF:

placeholder-moves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Paragraph Affects the Paragraph Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [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.

6 participants