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

Incorrect typing result when children mutation handler tries to fix nbsp character #3133

Closed
oskarwrobel opened this issue Sep 19, 2018 · 2 comments · Fixed by ckeditor/ckeditor5-typing#171
Assignees
Labels
package:typing type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@oskarwrobel
Copy link
Contributor

Steps to reproduce

For the following model:

<paragraph>
  <text bold="true" linkHref="sth">F[]</text><$text>oo&nbsp;bar</$text>
</paragrah>

type something e.g. x character .

Result

Selection went after &nbsp character and attributes are applied for the all text before the selection.

<paragraph>
  <text bold="true" linkHref="sth">Fxoo []</text><$text>bar</$text>
</paragrah>

Expected result

Selection should be placed after the new character

<paragraph>
  <text bold="true" linkHref="sth">Fx[]</$text><$text>oo&nbsp;bar</$text>
</paragrah>
@scofalik scofalik self-assigned this Oct 1, 2018
@scofalik
Copy link
Contributor

scofalik commented Oct 1, 2018

So, it seemed to me that the problem is in those two lines of code:

const newText = modelFromDomChildren.map( item => item.is( 'text' ) ? item.data : '@' ).join( '' ).replace( /\u00A0/g, ' ' );
const oldText = currentModelChildren.map( item => item.is( 'text' ) ? item.data : '@' ).join( '' );

Here we create two text strings which we will compare looking for changes. It seems that oldText should also have &nbsp; changed to regular spaces for comparison purposes. Of course there always may be some case that I forgot now, but that would make sense. Above those two lines of code is a comment that mentions _handleTextMutation function. In that function oldText has &nbsp replaced.

So I changed that and there are no errors in tests and the bug seems to be fixed 🤷‍♂️ .

oskarwrobel referenced this issue in ckeditor/ckeditor5-typing Oct 1, 2018
Fix: `&nbsp;` is now correctly handled in mutations. Closes #170.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-typing Oct 9, 2019
@mlewand mlewand added this to the iteration 20 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:typing labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:typing type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants