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

Cannot read properties of undefined (reading 'mouse') #2023

Open
aparzi opened this issue Nov 30, 2021 · 9 comments
Open

Cannot read properties of undefined (reading 'mouse') #2023

aparzi opened this issue Nov 30, 2021 · 9 comments

Comments

@aparzi
Copy link

aparzi commented Nov 30, 2021

Hi everyone,
I use jquery-ui: 1.13.0 in particullary widget draggable.js, in Angular 12. Bu when I refresh the page I get this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'mouse')
at draggable.js:39
at draggable.js:35
at draggable.js:37

Could anyone help me?
I could possibly also open a pull request because I added a code snippet that handles the error.

Thanks, I'm waiting for updates.

@mgol
Copy link
Member

mgol commented Nov 30, 2021

Thanks for the report. Does the issue you describe exist when jQuery UI 1.12.1 is used or only with jQuery UI 1.13.0 or newer? Also, please attach a test case on JS Bin showing the error.

@aparzi
Copy link
Author

aparzi commented Dec 1, 2021

Hi @mgol,
I solved my problem installed jquery-ui-dist: 1.12.1
However the issue happened either with JQuery 1.12.1 but also jQuery UI 1.13.0.
My code in angular is:

declare let $: any;

$(document).ready(() => {
    const modalContent: any = $('.modal-content');
    modalContent.draggable({
        handle: '.modal-header'
    });
});
@mgol
Copy link
Member

mgol commented Dec 1, 2021

Thanks for the report. Since the issue is already in 1.12, given limited team resources it's not likely to be fixed by the UI team; see the project status at https://blog.jqueryui.com/2021/10/jquery-maintainers-update-and-transition-jquery-ui-as-part-of-overall-modernization-efforts/. PRs are welcome, though.

Note that it would still be easier for whoever wants to look at this to have a working test case on JS Bin.

@mgol mgol removed the Needs info label Dec 1, 2021
@aparzi
Copy link
Author

aparzi commented Dec 1, 2021

Thanks @mgol,
my fix just handles undefined parameters, meaning I don't access properties that aren't defined.

@aparzi
Copy link
Author

aparzi commented Dec 3, 2021

Hi @mgol,
what do you think of the fix? should I push it?

@spapaseit
Copy link

spapaseit commented Jun 14, 2022

Hi @aparzi, I'm getting this same error with v1.12.1 and v1.13.1 (on the sortable widget, instead of draggable though).

Installing jquery-ui-dist 1.12.1 made no difference for me.
I know it's been a while but, would you mind explaining what you did to fix the problem?

Thanks a lot.

@spapaseit
Copy link

It just occurred to me to check the source for sortable.js, and I saw that the "offending" param was $.ui.mouse, so I tried importing the mouse widget and it seems to have worked:

from:

import "jquery-ui/ui/widgets/sortable";

to:

import "jquery-ui/ui/widgets/mouse";
import "jquery-ui/ui/widgets/sortable";
@aparzi
Copy link
Author

aparzi commented Jun 15, 2022

Hello @spapaseit,
I just handled some parameters which could be undefined. Having been a while, I don't remember specifically which classes I changed. If you want I can learn more...

@spapaseit
Copy link

Hi @aparzi, don't worry, the approach of my comment above works fine.
I appreciate the offer, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment