Opened 9 years ago

Closed 9 years ago

#13397 closed Bug (fixed)

D&D a widget inside its nested widget removes that widget

Reported by: Szymon Cofalik Owned by: Tade0
Priority: Normal Milestone: CKEditor 4.5.2
Component: General Version: 4.5.0
Keywords: Cc:

Description

When you create a widget inside a widget and then try to drag and drop the upper widget into the nested one, console reports an error and the whole structure disappears from editor.

Widget`s definition to use when reproducing:

CKEDITOR.plugins.add( 'mywidget', {
	requires: 'widget',

	init: function( editor ) {
		editor.widgets.add('widgetCast', {
			button: 'Create mywidget',

			template: '<div class="row layout-row">\
					 <div class="c1" style="padding:10px;border:1px dashed black;float:left;width:100%;box-sizing:border-box;">\
						 <p></p>\
					 </div>\
				</div>',

			upcast: function(element) {
				return (element.name == 'div' && element.hasClass('layout-row'));
			},

			editables: {
				c1: {
					selector: '.c1'
				}
			}

		});
	}
} );

(extra styling for easier reproduction).

Steps to reproduce:

  1. Create instance of mywidget.
  2. Create another instance of mywidget into previously created one.
  3. Select the first instance.
  4. Drag and drop it into nested instance.

Result: Both widgets disappear.

Expected result: Dropping a widget inside itself should not be possible and there should be no helping line when trying to do so.

Change History (10)

comment:1 Changed 9 years ago by Jakub Ś

Status: newconfirmed

comment:2 Changed 9 years ago by Artur Delura

comment:3 Changed 9 years ago by Tade0

Owner: set to Tade0
Status: confirmedassigned

comment:4 Changed 9 years ago by Tade0

Status: assignedreview

Changes pushed to branch:t/13397.

comment:5 Changed 9 years ago by Piotrek Koszuliński

How is this place different from others in which we do early return that you cancel the event only in this single place?

comment:6 Changed 9 years ago by Piotrek Koszuliński

As we agreed during live discussion, this issue should be fixed even before this code is executed. Line utils should not display (and handle) drop locations inside a widget being dragged. This is the minimal fix which is enough for now.

In the future, when perhaps inline widgets will be given support for nested editables, that condition which was added in editor#drop will make sense. But for now it's unnecessary as long as line utils is properly configured.

comment:7 Changed 9 years ago by Piotrek Koszuliński

Status: reviewreview_failed

comment:8 Changed 9 years ago by Tade0

Status: review_failedreview

Changes pushed to ​branch:t/13397.

comment:9 Changed 9 years ago by Tade0

Changes pushed to branch:t/13397a.

comment:10 Changed 9 years ago by Piotrek Koszuliński

Resolution: fixed
Status: reviewclosed
Summary: D&D a widget inside it's nested widget removes that widget.D&D a widget inside its nested widget removes that widget

Fixed on master with git:fa71d86.

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