Opened 13 years ago

Last modified 13 years ago

#7928 confirmed Bug

elementspath + getSelectedElement problem

Reported by: daveVW Owned by:
Priority: Normal Milestone:
Component: General Version: 3.6
Keywords: Cc:

Description

When you click an element in the elements path, the elementspath.js plugin executes the instruction

editor.getSelection().selectElement(element);

However, in all browsers except Firefox, the editor.getSelection().getSelectedElement() returns null !

Is this a problem that has been solved already in some patch ?

Attachments (1)

Error.jpg (150.2 KB) - added by daveVW 13 years ago.
Menu item selected

Download all attachments as: .zip

Change History (12)

comment:1 Changed 13 years ago by Jakub Ś

Status: newpending

Ok the function returns null but what sort of error does it cause in CKEditor itself?

Could you provide us with a sample test case showing the problem in more detail?

comment:2 Changed 13 years ago by daveVW

This doesn't pose a problem in CKEditor as is. But it gives a problem when adding new plugings. I am writing a styleEditor plugin for adding styles to a given selection. If one makes a selection using the elementspath then following happens :

  1. In Firefox, the element is selected (editor.getSelection().getSelectedElement()). Hence, the styleEditor plugin will add new styles to the element.
  2. But in other browsers, the element is NOT selected (getSelectedElement() is null). Hence, the styles will be applied to the selected text using a span element. But the user expects of course the styles to be added to the element itself because he selected the element in the elementspath.

But why does the following elementspath instruction

editor.getSelection().selectElement(element);

fails ?

comment:3 Changed 13 years ago by daveVW

Problems using IE 7, 8 & 9 when using the elementspath ! Try the following :

  1. Create new table
  2. Put the cursor in a cell
  3. Click "td" in the elementspath : JAVASCRIPT ERROR

Second example :

  1. Create new table
  2. Put the cursor in a cell
  3. Add some text in the cell
  4. Click "td" in the elementspath
  5. Go to cell properties and change the width of the cell
  6. Save : JAVASCRIPT ERROR

Third example : problem in IE 7, 8 (not in v9)

  1. Create new table
  2. Put the cursor in the table
  3. Click 'table' in the elementspath
  4. Choose table properties in the context menu and change the height of the table to 200
  5. Click save
  6. Click on table properties in the context menu again: the menu item becomes selected and you are blocked.

I think all these problems are related to the getSelectedElement problem which returns null.

comment:4 Changed 13 years ago by Jakub Ś

  1. modifiy sample text on page
    <strong id="abc"
    
  1. Paste the code below:
    setTimeout(function(){	
    	var element2 = CKEDITOR.instances.editor2.document.getById( 'abc' );
    	//alert(element2.getName());
    	CKEDITOR.instances.editor2.getSelection().selectElement( element2 );
    	alert(CKEDITOR.instances.editor2.getSelection().getSelectedElement()); 
    },6000);
    
  2. Results:
    FF, Webkit and Opera all select element strong but getSelectedElement() method returns null. All IEs throw JS error that selectElement is either empty or undefined.

This hasn't worked from CKEditor 3.0

comment:5 Changed 13 years ago by Jakub Ś

@daveVW

I have created two new tickets based on your comment no 3.

Example 1 #7975 and Example 2 #7976

Example 3 I could not reproduce this one. could you explain point 6 in more detail. How do you select table properties again. Do you click on elementspath than on table with RBM and select table properties or you click on table with RBM and select table properties from menu? None of this resulted in error. I think I'll be needing your help on this one.

Changed 13 years ago by daveVW

Attachment: Error.jpg added

Menu item selected

comment:6 Changed 13 years ago by daveVW

I've added an attachment to show the error : menu item selected. The problem occurs on IE 7 & 8.

  1. Create new table
  2. Put the cursor in the table
  3. Click 'table' in the elementspath
  4. Right-click and choose table properties in the context menu. Change the height of the table to 200.
  5. Click OK button
  6. Right-click again and choose table properties in the context menu : the menu item becomes selected and you are blocked.

Don't know what you mean with RBM.

comment:7 Changed 13 years ago by Jakub Ś

Sorry typo. I meant RMB - right mouse button.

comment:8 Changed 13 years ago by Frederico Caldeira Knabben

Click with RMB. (what?)
Right-click. (shorter and easier to understand)

comment:9 Changed 13 years ago by Jakub Ś

Status: pendingconfirmed

I have managed to reproduce third example. It is described in #7978.

This ticket is reproducible from 3.0

comment:10 Changed 13 years ago by daveVW

I read #7978 but that is not the problem I experience here. Take a look at the image I uploaded before (error.jpg). When the right-click menu opens and I click on 'table properties', then the menu option itself becomes selected instead of opening the dialog (see the selection border on the image).

comment:11 Changed 13 years ago by Jakub Ś

That is what I meant in #7978. I have changed the description of that ticket so that it is less confusing.

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