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

TippyJS crashes when I use non basic types in PopperJS configuration #736

Closed
marimeireles opened this issue Mar 15, 2020 · 1 comment
Closed

Comments

@marimeireles
Copy link

Bug description

I'm using a wrapper library for PopperJS called cytoscape-popper. PopperJS uses TippyJS to show tips given an element.

My specific use case is that I'm porting this cytoscape-popper library as a widget to Jupyter notebook and to do that I need to use Typescript.

Now, I'm having some issues when I try to use non-basic types like lists and dictionaries on the configuration of my tips. If I try to use options like the following on my tip:

   if (node.data().name){
      let tip = Tippy(dummyDomEle, {
        trigger: 'manual',
        lazy: false,
        //bools or strings won't cause any problem
        arrow: true,
        theme: 'material',
        placement: 'bottom',
        //it only crashes if I use types like lists, etc
        offset: [0, 10],
        content: () => {
          let content = document.createElement('div');
          content.innerHTML = node.data().name;
          return content;
        },
        onCreate: instance => { instance!.popperInstance!.reference = ref; } // needed for `ref` positioning
      });
      tip.show();
    }

I'll run to the following error:

          TS2345: Argument of type '{ trigger: string; lazy: false; arrow: true; theme: string; placement: "bottom"; offset: number[]; content: () => HTMLDivElement; onCreate: (instance: Instance<Props>) => void; }' is not assignable to parameter of type 'Partial<Props>'.
      Types of property 'offset' are incompatible.
        Type 'number[]' is not assignable to type 'string | number | undefined'.
          Type 'number[]' is not assignable to type 'number'.

I've opened a similar issue to this one on the popper-cytoscape page and in the opinion of the maintainer this is likely a TippyJS problem with Typescript.

Do you have any known issues with Typescript, any idea of what might be happening here?

These are my relevant dependencies:

    "cytoscape": "^3.14.0",
    "cytoscape-cola": "^2.3.0",
    "cytoscape-popper": "^1.0.6",
    "popper": "^1.0.1",
    "tippy.js": "^5.2.1"
    "typescript": "~3.1.2",

Reproduction

I can create a small reproducible example if you're interested in testing it yourself, as well explain the setup to run a Jupyter widget.

Thank you very much.

@atomiks
Copy link
Owner

atomiks commented Mar 16, 2020

You've installed 5.x but using 6.x props, you can either use the v5 docs or upgrade to v6 and it should work fine 🤗

btw, popper is not a library that needs to be installed (it's not the correct name)

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

No branches or pull requests

2 participants