Approved
Last Updated: 17 Jan 2019 09:50 by ADMIN
Mihajlo
Created on: 17 Jan 2019 09:43
Category: RichTextEditor
Type: Bug Report
1
FIX. RadRichTextEditor - MoveToDocumentElementStart works incorrectly when called consecutively with PermissionRangeStart as parameter
RadRichTextEditor: MoveToDocumentElementStart works incorrectly when called consecutively with PermissionRangeStart as parameter
When the MoveToDocumentElementStart is called with parameter that is PermissionRangeStart and then is called a second time, the position moves to the previous position instead.


1 comment
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 17 Jan 2019 09:50
Hello, Mihajlo,

I have logged it in our feedback portal by making this thread public.  

I have also updated your Telerik points.

This can be avoided with the following workaround: 

private void radRichTextEditor1_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
    if (e.Command is MoveCaretCommand)
    {
        if ((MoveCaretDirections)e.CommandParameter == MoveCaretDirections.DocumentStart)
        {
            PermissionRangeStart permissionRangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType<PermissionRangeStart>().FirstOrDefault();
  
            if (permissionRangeStart != null)
            {
                e.Cancel = true;
  
                if (this.CheckIfPositionIsAtPermissionRangeStart(permissionRangeStart))
                {
                    this.radRichTextBox.Document.CaretPosition.MoveToDocumentElementStart(permissionRangeStart);
                }
            }
        }
    }
}
  
private bool CheckIfPositionIsAtPermissionRangeStart(PermissionRangeStart permissionRangeStart)
{
    DocumentPosition permissionRangePosition = new DocumentPosition(this.radRichTextBox.Document);
    permissionRangePosition.MoveToDocumentElementStart(permissionRangeStart);
    permissionRangePosition.MoveToNextInline();
  
    return this.radRichTextBox.Document.CaretPosition != permissionRangePosition;
}


Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.