Skip to content

OverlayTrigger with delays can unintentionally leave overlays visible due to focus events. #795

@ElsewhereGames

Description

@ElsewhereGames

If you use a Tooltip with an OverlayTrigger and specify show and hide delays, there is a way to keep the tool-tip open indefinitely, even after the cursor leaves the OverlayTrigger: Mouse over the trigger, wait for the tool-tip to appear, then rapidly click and drag mouse the cursor off the component. I was able to reproduce this behavior in Chrome, Firefox, and Internet Explorer.

This behavior can be demonstrated using the sample code from the documentation:

const LinkWithTooltip = React.createClass({
  render() {
    let tooltip = <Tooltip>{this.props.tooltip}</Tooltip>;

    return (
      <OverlayTrigger placement='top' overlay={tooltip} delayShow={300} delayHide={150}>
        <a href={this.props.href}>{this.props.children}</a>
      </OverlayTrigger>
    );
  }
});

Place this link anywhere, click and drag off the link quickly, and the tooltip will remain open.

I dove into the OverlayTrigger code a bit, and it seems the mouse click triggers a call to handleDelayedShow() (since that gives the wrapped component focus), which sets the _hoverDelay property. When handleDelayedHide() is invoked right after, it will just call clearTimeout(this._hoverDelay) and return, thus keeping the tooltip visible.

I think this behavior can be disabled by only specifying hover as a trigger. Perhaps focus should not be a default trigger?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions