question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip.updateTitleContent() and default options.innerSelector don't work well together

See original GitHub issue

CodePen demo

https://codepen.io/anon/pen/WgRoZp?editors=1111

Steps to reproduce the problem

  1. Notice that all 4 tooltips start out with “default title”, as they should
  2. Hover over all 4 li elements
  3. Notice that only 1 tooltip has updated to “updated title”

What is the expected behavior?

All 4 should have updated.

What went wrong?

The code you use in your _updateTitleContent (in index.js) function looks like:

  _updateTitleContent(title) {
    if(typeof this._tooltipNode === 'undefined') {
      if(typeof this.options.title !== 'undefined') {
        this.options.title = title;
      }
      return;
    }
    const titleNode = this._tooltipNode.parentNode.querySelector(this.options.innerSelector);
    this._clearTitleContent(titleNode, this.options.html, this.reference.getAttribute('title') || this.options.title)
    this._addTitleContent(this.reference, title, this.options.html, titleNode);
    this.options.title = title;
    this.popperInstance.update();
  }

Why do you use .parentNode? I think that should be removed. I would think the innerSelector should be scoped so it selects descendants of the root tooltip element. But, by using parentNode, you select from the next parent up instead (in my case, parentNode is the ul element). This causes the innerSelector to find too many matches, and an arbitrary single match is chosen by querySelector(), causing only a single tooltip update.

Also, note that this is only a problem when you have more than 1 tooltip with the same parent, like I do with my ul and 4 li tooltip children.

Any other comments?

This is default config, and it’s broken. I don’t think telling people to choose a more distinct/selective innerSelector would be a good solution to this. It would work, but pushes tedious bookkeeping onto the client to create unique ids and stick them into the innerSelector.

Off topic - thanks for the great work on this lib!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jsmnbomcommented, Mar 21, 2019

@FezVrasta It looks like this has been merged? If so, could you maybe release a new release on NPM with the fix?

0reactions
FezVrastacommented, Apr 11, 2019

I already released the fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

customize innerSelector and arrowSelector in the Tooltip Class
Its an actual issue, because if i have two or more tooltips (trigger: "manual") and i need to update title of one by...
Read more >
tooltip.js - UNPKG
The CDN for tooltip.js. ... variable to check\n * @returns {Boolean} answer to: is a function?\n */\nexport default function isFunction(functionToCheck) {\n ...
Read more >
Falcon Sandbox v8.49.3 © Hybrid Analysis
This report is generated from a file or URL submitted to this webservice on October 8th 2021 20:37:11 (UTC) and action script Default...
Read more >
Toadhttpd: Check-in [9c95e7e40b] - Etoyoc.com!
Popper = factory()); }(this, (function () { 'use strict'; var isBrowser = typeof ... from 0 */ /** * Default options provided to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found