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

(Bug report) Warnings in console "Custom widget does not have mandatory 'getParent()' method defined" #4248

Open
sottey opened this issue Sep 7, 2023 · 9 comments

Comments

@sottey
Copy link

sottey commented Sep 7, 2023

Trilium Version

0.60.4

What operating system are you using?

Ubuntu

What is your setup?

Server access only

Operating System Version

Ubuntu 20

Description

Not a big deal, but something is causing the error:

"Custom widget does not have mandatory 'getParent()' method defined"

I have disabled all of my widgets and it is still occurring, so I wonder if it is an issue in the services.js...

Error logs

image

@zerebos
Copy link
Collaborator

zerebos commented Sep 7, 2023

I checked my server instance and don't see the same thing

@sottey
Copy link
Author

sottey commented Sep 7, 2023

Hmm. I will continue looking at my implementation. thanks!

@zadam
Copy link
Owner

zadam commented Sep 7, 2023

How did you disable those custom widgets?

The algorithm is to find all notes with label #widget and those classes have to have a parentWidget property, like:

class WordCountWidget extends api.NoteContextAwareWidget {
    get position() { return 100; } // higher value means position towards the bottom/right

    get parentWidget() { return 'center-pane'; }
    ...
}

@sottey
Copy link
Author

sottey commented Sep 7, 2023

My habit is to change #widget to #DISABLEDwidget and reload the frontend. Is it possible that this is causing the issue?

@sottey
Copy link
Author

sottey commented Sep 7, 2023

...or perhaps I am using #widget improperly... I use this for items I want to be able to call via key combos or events.

@zadam
Copy link
Owner

zadam commented Sep 7, 2023

My habit is to change #widget to #DISABLEDwidget and reload the frontend. Is it possible that this is causing the issue?

Sounds okay.

...or perhaps I am using #widget improperly... I use this for items I want to be able to call via key combos or events.

Not sure what this means. Notes with #widget are expected to contain widget classes similar to the one I posted above.

If you just want a random JS code run on the frontend startup, then it's better to use #run=frontendStartup

@zerebos
Copy link
Collaborator

zerebos commented Sep 7, 2023

iirc the usage of the term "widget" comes from jQuery UI so as zadam said for just making keyboard shortcuts and such that don't require a UI, no need to make it a widget!

@zadam
Copy link
Owner

zadam commented Sep 8, 2023

iirc the usage of the term "widget" comes from jQuery UI

Hmm, not really. widget is just a general UI concept

Trilium used jQuery UI in early versions for a couple of things, but now it's gone. It's true that the whole Trilium uses jQuery core for selectors etc (it's just more egonomic API than the native DOM), including widgets, but Trilium widgets otherwise don't come from jQuery world.

zadam said for just making keyboard shortcuts and such that don't require a UI, no need to make it a widget!

Yes, "widget" is useful when you need an UI. Could be used also for non-UI things if you need to listen to application events (it's added to the component tree through which events flow).

But if you just need some basic script, then it's not necessary to use widgets ...

@zerebos
Copy link
Collaborator

zerebos commented Sep 8, 2023

Ah that's my mistake, an interesting overlap though.

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

No branches or pull requests

3 participants