Opened 11 years ago

Last modified 10 years ago

#9929 closed Bug

[Chrome 23]   is created when deleting character and typing common space — at Version 9

Reported by: sir qwerty Owned by:
Priority: Normal Milestone: CKEditor 4.2.3
Component: Core : Keystrokes Version: 4.0
Keywords: WebKit Blink Cc:

Description (last modified by Jakub Ś)

This is new erroneous behavior in CKEditor 4 using Chrome 23, Win7 x64. Steps to reproduce:

  1. go to official demo page of CKEditor 4, wysiwyg mode
  2. delete any character using backspace or delete key
  3. immediately type a space just by plain spacebar
  4. see the source - nbsp is created instead of common space char

On my configuration SCAYT is disabled, no difference.


Another TC:

  1. Insert below code into editor and switch to WYSIWYG:
    <p>This is a simple sentence.</p>
    
  2. Delete all spaces and create them again

Result:

<p>This&nbsp;is&nbsp;a&nbsp;simple&nbsp;sentence.</p>

Problem can be reproduced in Blink and Webkit.

Change History (9)

comment:1 Changed 11 years ago by Jakub Ś

Keywords: nbsp space removed
Version: 4.0.13.0

This behaviour can actually be reproduced on Opera, Safari and Chrome from CKEditor 3.0 and you don’t need to press delete to get this result. Single space is enough. I'm not sure if this is a bug as this is how these browsers behave. It can be checked with page holding div with contenteditable="true" attribute.

comment:2 Changed 11 years ago by Piotrek Koszuliński

Status: newconfirmed

Kuba, you're not right here. This backspace changes behaviour.

  1. Type 'foooo' and place caret in the middle of this word.
  2. Press delete.
  3. Press space.
  4. Result: 'fo&nbsp;oo'.
  1. Type 'foooo' and place caret in the middle of this word.
  2. Press space.
  3. Result: 'foo oo'.

I can't find a reason explaining first behaviour and I cannot reproduce it on native contentediable, so it's somehow caused by editor.

comment:3 Changed 11 years ago by Jakub Ś

Keywords: Webkit added
Version: 3.04.0

@Reinmar you are right. Problem can be reproduced in Webkit browsers only from CKEditor 4.0 (3.x and 4 beta are free of this bug).

comment:4 Changed 11 years ago by Niklas

Is there anything happening with this bug?

comment:5 Changed 11 years ago by Niklas

I started to look into this. With Chrome's developer tools I found out a part of the reason for this:

I demonstrate DT output here:

Step 1: The beginning. I added new row with enter and typed "foobar". Everything seems to be ok.

<p>
  "foobar"
</p>

Quotes are extra, the actual data is <p>foobar</p>, but Chrome seems to break it into more peaces.

Step 2: Press backspace for "b". DT output becomes

<p>
  "foo"
  "ar"
</p>

The editor now shows it as "fooar", so there is no space between "foo" and "ar".

Step 3: Add space between "o" and "a". DT shows this:

<p>
  "foo&nbsp;"
  "ar"
</p>

It seems as on backspace/delete string is exploded into substrings for some reason and adding space to an end of a substring is converted into &nbsp;. If I type a "b" after "foo&nbsp;" it becomes:

<p>
  "foo b"
  "ar"
</p>

comment:6 Changed 11 years ago by Niklas

I think this issue can be fixed with very easy solution:

Replace

else if ( range.collapsed )
{
	// Handle the following special cases: (#6217)
	// 1. Del/Backspace key before/after table;
	// 2. Backspace Key after start of table.
	if ( ( block = path.block ) &&
		 range[ rtl ? 'checkStartOfBlock' : 'checkEndOfBlock' ]() &&
		 ( next = block[ rtl ? 'getPrevious' : 'getNext' ]( isNotWhitespace ) ) &&
		 next.is( 'table' ) )

with

else if ( range.collapsed )
{
	// Handle the following special cases: (#6217)
	// 1. Del/Backspace key before/after table;
	// 2. Backspace Key after start of table.
	if ( ( block = path.block ) &&
		 ( next = block[ rtl ? 'getPrevious' : 'getNext' ]( isNotWhitespace ) ) &&
		 next.is( 'table' ) &&
		 range[ rtl ? 'checkStartOfBlock' : 'checkEndOfBlock' ]() )

This way dom does not get changed by these checks if del/backspace is not table related.

comment:7 Changed 11 years ago by Niklas

I made a pull request for this: https://github.com/ckeditor/ckeditor-dev/pull/46

comment:8 Changed 11 years ago by sir qwerty

Almost a year and still producing tons and tons of unwanted &nbsp; entities during daily usage of CKeditor in Chrome for Windows. Just sweet.

comment:9 Changed 11 years ago by Jakub Ś

Description: modified (diff)
Keywords: Blink added
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy