Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13218 closed Bug (fixed)

"Uncaught TypeError: Cannot read property 'filter' of undefined " and "Uncaught TypeError: Cannot read property 'removeClass' of undefined " after widget drop

Reported by: Radoslav Petkov Owned by: Szymon Cofalik
Priority: Normal Milestone:
Component: UI : Widgets Version: 4.5.0 Beta
Keywords: Cc:

Description

I have strange behaviour with my custom widget that does not happen on other widgets.I thought it is from my plugin.js but it seems the error comes from the CKEditor's widget api and i wanted to share the errors with you.

The attached gif shows in what situation the errors occur.

Here is the code that defines the widget

    editor.widgets.add('widgetCast', {
        template: '<div class="container-fluid layout-container">\
                        <div class="row layout-row">\
                             <div id="layout-column-one" class="col-xs-6 col-sm-6 col-md-6 col-lg-6 layout-column">\
                                 <p>content</p>\
                             </div>\
                            <div id="layout-column-two" class="col-xs-6 col-sm-6 col-md-6 col-lg-6 layout-column">\
                                <p>content</p>\
                            </div>\
                        </div>\
                    </div>',
        upcast: function(element) {
            return (element.name == 'div' && element.hasClass('layout-container'));
        },
        editables: {
            layoutColumn1: {
                selector: '#layout-column-one',
                allowedContent: allowedContent
            },
            layoutColumn2: {
                selector: '#layout-column-two',
                allowedContent: allowedContent
            }
        },
        allowedContent: allowedContent
    });

Attachments (4)

widgetBug1.gif (234.6 KB) - added by Radoslav Petkov 4 years ago.
Gif representing the issue
dropWidgetFilterRemove.gif (138.9 KB) - added by Radoslav Petkov 4 years ago.
Another gif representing the same issue
mywidget.zip (771 bytes) - added by Jakub Ś 4 years ago.
mywidget2.zip (775 bytes) - added by Jakub Ś 4 years ago.

Download all attachments as: .zip

Change History (13)

Changed 4 years ago by Radoslav Petkov

Attachment: widgetBug1.gif added

Gif representing the issue

Changed 4 years ago by Radoslav Petkov

Attachment: dropWidgetFilterRemove.gif added

Another gif representing the same issue

comment:1 Changed 4 years ago by Radoslav Petkov

I think this happens because i am using id as selector and when i insert multiple widgets there are elements in the dom with same ids which is contradicting with the definition of id : 'You can only use an ID name once in any XHTML or HTML document.' Am i right?

Changed 4 years ago by Jakub Ś

Attachment: mywidget.zip added

comment:2 Changed 4 years ago by Jakub Ś

Keywords: widget filter removed
Status: newconfirmed

I have recreated (sort of) this widget. @rpet please review it and tell me if this is what you use?


I think this ticket is valid after all.

I don't think it is good approach to use ids as in such case thus I have changed it to class. (moved id to class and changed the selector (from # to .))

I have then tried moving around the widget until I do to situation shown on overlapping_handles.png. Once you try moving widget from there you are getting JS error thrown.

comment:3 Changed 4 years ago by Radoslav Petkov

Yup thats it, but actually yours is getting this error thrown faster than my previous version.However i have fixed it by using classnames as selectors.

Changed 4 years ago by Jakub Ś

Attachment: mywidget2.zip added

comment:4 Changed 4 years ago by Jakub Ś

@rpet are you able to get scenario where you have overlapping drag handles with your plugin? Are you getting any error then?

I have attached mywidget2 plugin where ids were changed to classes however I'm still getting the error with above scenario. Are there any core differences between your and my sample plugin?

comment:5 Changed 4 years ago by Radoslav Petkov

Strangely but, yes I broke yours then I broke mine the same way.The bug stays.

Version 0, edited 4 years ago by Radoslav Petkov (next)

comment:6 Changed 4 years ago by Szymon Cofalik

Owner: set to Szymon Cofalik
Status: confirmedassigned

comment:7 Changed 4 years ago by Szymon Cofalik

Probably will be fixed by #13334 . Will check it after reviewing #13334.

Last edited 4 years ago by Szymon Cofalik (previous) (diff)

comment:8 Changed 4 years ago by Szymon Cofalik

Resolution: fixed
Status: assignedclosed

Fixed by #13128

comment:9 Changed 4 years ago by Szymon Cofalik

Error discussed in comment:2 and further will be fixed in #13397.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy