-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Firefox: RichText: invisible trailing <br> tags #5872
Comments
Thanks for reporting this... I experienced this issue back in Gutenberg 2.3 while writing a post, but I forgot to create an issue about it. I did some quick testing just now in Gutenberg 2.5, and it looks like if you press EDIT: I also did a quick test in Gutenberg 0.1, and it looks like the above-described behavior happens in that version as well. So this appears to be an issue that has always existed with the Header block. |
@SuperGeniusZeb I'm getting |
My hunch is that this is an artifact of the Rich Text component, as I don't see anything in the heading block that relates to managing |
As @danielbachhuber suspects, it's not related to the heading as this also happens on regular paragraph blocks. However, it doesn't happen when creating a Classic block. |
I am not able to reproduce this on master. Can anyone else on this ticket still reproduce it? |
Tested using WordPress 4.9.8 and Gutenberg 4.1.1 using Firefox 62.0.3 on macOS 10.13.6 with the steps provided and I don't see any extra
Closing since the last two reports on this thread note that the problem cannot be reproduced in later versions. If you're still having trouble and can think of something we may be missing in our testing steps, please comment and we'll re-open! |
I'm seeing this behavior in WP 4.9.8 and Gutenberg 4.1.1. All I do is update the content in a RichText component and the |
Possibly related to #11037 @danielbachhuber is there a way for me to test with your custom block? I can't seem to duplicate this or the issue in #11037 - running latest Gutenberg on 4.9.8 We've seen this issue occur with conflicts with the wpautop priority change and plugins that filter the_content, which should be fixed in this core ticket: https://core.trac.wordpress.org/changeset/43879 |
@mkaz Yes, I'll see if I can put together a custom block that reproduces the issue. This is against latest Gutenberg running 4.9.8 |
@mkaz This snippet reproduces regularly for me:
Notice the Notably, the |
Also worth noting: the |
Sorry, clicked the wrong button. I see the same issue in Chrome for me ( v70 on macOS) |
Moving this to 5.0 if it can be addressed. |
Thanks for the detailed steps @danielbachhuber. I'll work on a fix right now. |
Firefox inserts this line break element to ensure the spaces you type at the end of an editable element stay visible. Normally in HTML, spaces, newlines and tabs are used to format HTML. In between words they are reduced to one visible space. Any leading spaces or trailing spaces are simply omitted. Browser work around this problems in different ways. Chrome inserts non breaking spaces, which it (most of the time) removes again when it no longer needs them. This is an equally terrible way of fixing the problem, because when Chrome doesn't remove the non breaking spaces, they mess up the user's content. Firefox fixes the issue with a trailing line break, and doesn't remove it when the line no longer ends with a space, so it gets included in the content as well. We cannot simply remove it because RichText is a controlled component. Any changes to the value flow back into the live DOM. Removing the line break would break Firefox ability to display trailing space characters when typing. I think the best way to deal with this is to come up with a way to fix this in all browsers the same way and build it into RichText. That's what I'm attempting right now. |
Since there should be no visual difference on the front-end either, I'm going to move this issue to 5.0.1. |
@iseulde Just to be clear, there is a visual difference on the frontend: the |
@danielbachhuber Is that with core blocks? I can't reproduce that. Note that if you use |
@iseulde It's with this code snippet: #5872 (comment)
I don't understand. Can you clarify? My current implementation is this:
|
@danielbachhuber What happens if you make some text italic (cmd+i)? Will that also de encoded? I think you need to same the content with |
@iseulde Oh, huh. Maybe developer error then. I'll look into this next week. |
The issue with the trailing line break is valid, but it's not a blocker. It shouldn't display on the front end if the rich text content is saved correctly. There will just be a trailing line break in the HTML, which isn't that bad. |
#12166 should fix this issue. |
I am still seeing this as of updating to WP5.0-RC2-43958. Relevant code: const { registerBlockType } = wp.blocks;
const {
MediaUpload,
RichText,
} = wp.editor;
const {
Button,
TextControl
} = wp.components;
registerBlockType(
'aw/floor-plan-in-content', {
title: __('Floor Plan'),
icon: 'index-card',
category: 'common',
attributes:{
title: {
type: 'string',
source: 'text',
selector: '.fp_header'
},
// ...
},
edit: props => {
const {
// ...
title,
// ...
} = props;
return(
<div className = { props.className }>
<RichText
tagName = "h2"
className = "fp_header widefat"
placeholder = {__("Floor Plan name")}
keepPlaceholderOnFocus={ true }
value = { title }
onChange= { onChangeTitle }
multiline = { false }
formattingControls = { [] }
/>
// ...
</div>
)
},
save: props => {
const {
attributes: {
title,
// ...
}
} = props;
return (
<div className={"floorplan-display" }>
// ...
<RichText.Content
tagName = "h2"
className = "fp_header"
value = { title }
/>
// ...
</div>
)
}
}
); Console error:
Note the |
I am still getting |
This PR is not included in a release yet. |
Issue Overview
I have a page with a number of different Heading blocks. Some of the blocks display fine on the front-end (e.g.
<h3>Some text</h3>
) and other headings have an extra<br>
tag included (e.g.<h3>Some text<br></h3>
)These couple of headings are displaying fine
This heading has the extra
<br>
tagWhen you look at the block with the extra tag, in the Visual Editor, it appears fine. If I click in the block and try to remove any extra (invisible) characters from the end, I can't.
If I switch to the Code Editor, I can see the extra
<br>
tag which I never put in and I can't remove (using the Visual Editor).Steps to Reproduce (for bugs)
Expected Behavior
Headers shouldn't randomly include
<br>
tagsCurrent Behavior
Headers randomly include extra markup that you can't get rid of
Gutenberg 2.5.0
Firefox Quantum 59.0.2 (64-bit)
WP 4.9.4
The text was updated successfully, but these errors were encountered: