Skip to content

Tooltip mixin doesn't support multiple tooltips in the same Vue component

The Vue tooltip mixin doesn't support multiple tooltips in the same Vue component.

this.$refs.tooltip only represents a single element and is holds the latest ref="tooltip" in the DOM for a given component.

In this example, only bar will get a tooltip

<script>
import tooltipMixin from '../../vue_shared/mixins/tooltip';

export default {
  mixins: [
    tooltipMixin,
  ],
};
</script>
<template>
  <div
    title="fooooooooooooooooooooooo"
    ref="tooltip">
    foo
  </div>
  <div
    title="baaaaaaaaaaaaaaaaaaarrrr"
    ref="tooltip">
    bar
  </div>
</template>

Current usage with multiple tooltips that is broken:


We could workaround and use the existing mixin code by creating new Vue components to nest in order to get a new fresh namespace.


cc @filipa

Edited by Eric Eastwood