Reference Source
import Tooltip from 'flarum/common/components/Tooltip'
public class | source

Tooltip

Extends:

src/common/Component.js~Component → Tooltip

The Tooltip component is used to create a tooltip for an element. It requires a single child element to be passed to it. Passing multiple children or fragments will throw an error.

You should use this for any tooltips you create to allow for backwards compatibility when we switch to another tooltip library instead of Bootstrap tooltips.

If you need to pass multiple children, surround them with another element, such as a <span> or <div>.

Note: this component will overwrite the title attribute of the first child you pass to it, as this is how the current tooltip system works in Flarum. This shouldn't be an issue if you're using this component correctly.

Example:

Basic usage
         <Tooltip text="You wish!">
           <Button>
             Click for free money!
           </Button>
         </Tooltip>
Use of `position` and `showOnFocus` attrs
         <Tooltip text="Woah! That's cool!" position="bottom" showOnFocus>
           <span>3 replies</span>
         </Tooltip>
Incorrect usage
         // This is wrong! Surround the children with a <span> or similar.
         <Tooltip text="This won't work">
           Click
           <a href="/">here</a>
         </Tooltip>

Member Summary

Public Members
public
public
public

oldText: *

public
public
public

Method Summary

Public Methods
public

Checks if the tooltip DOM node has changed.

public
public
public

oncreate(vnode: *)

public

onupdate(vnode: *)

public
public
public

view(vnode: *): *

Public Members

public childDomNode: * source

public firstChild: * source

public oldText: * source

public oldVisibility: * source

public shouldChangeTooltipVisibility: * source

public shouldRecreateTooltip: * source

Public Methods

public checkDomNodeChanged() source

Checks if the tooltip DOM node has changed.

If it has, it updates this.childDomNode to the new node, and sets shouldRecreateTooltip to true.

public createTooltip() source

public getRealText(): * source

Return:

*

public oncreate(vnode: *) source

Params:

NameTypeAttributeDescription
vnode *

public onupdate(vnode: *) source

Params:

NameTypeAttributeDescription
vnode *

public recreateTooltip() source

public updateVisibility() source

public view(vnode: *): * source

Params:

NameTypeAttributeDescription
vnode *

Return:

*