Skip to content

Extra mxToolip elements created in the DOM #200

@tbouffard

Description

@tbouffard

mxToolip DOM elements are created to render Tooltips. Currently in v0.2.0, one or several mxTooltip elements are created in the DOM even if Tooltips are not used.
I don't see any reason to create such elements and they were not created in the former mxGraph implementation.

This can be reproduce with Storybook stories, with the ts-example of this repository and examples of https://github.com/maxGraph/maxgraph-integration-examples

extra_mxTooltip_with_ts-example_2023-06-07
DOM snapshot of the ts-example

mxGraph examples showing there wasn't extra tooltip element

First analysis

In mxGraph, the div was created only when calling the show method (if it didn’t previously exist):

The div in maxGraph is currently created in the constructor: https://github.com/maxGraph/maxGraph/blob/v0.10.2/packages/core/src/view/handler/TooltipHandler.ts#L51-L55
This means that if the TooltipHandler plugin is declared at Graph initialization (default behavior), a tooltip div is always created even if it is never used.

The behavior should be restored (lazy loading) and the init method could be renamed into ensureDivIsAvailable if there is a naming clarification to do (this would reduce the compatibility with mxGraph).

Notes for implementation

It should be feasible to add an automatic test that reproduce this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions