Skip to content

Implement tooltip API for the following actions

Enrique Alcántara requested to merge 229044-tooltips-hide-and-disable into master

What does this MR do?

This Merge Request continues the work started in:

This MR has the goal of exposing an API to perform the following actions in tooltips:

  • Enable/disable a tooltip.
  • Hide/show a tooltip.
  • Update a tooltip’s content based on the target’s title.

How to test?

Replace the following snippet in app/assets/javascripts/main.js:

  // Initialize tooltips
  $body.tooltip({
    selector: '.has-tooltip, [data-toggle="tooltip"]',
    trigger: 'hover',
    boundary: 'viewport',
    delay,
  });

with

  initTooltips('.has-tooltip, [data-toggle="tooltip"]:not([data-original-title])', {
    triggers: 'hover',
    boundary: 'viewport',
  });

Afterwards, you can find any place in the application where Bootstrap’s tooltip API is called and replace that API call with the API created on this MR. For example, you can replace the following API call in https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/project_label_subscription.js#L69:

import { fixTitle } from '~/tooltips';

// replace this
$button.attr('title', newTitle).tooltip('_fixTitle');

// with this
fixTitle($button);

Or you can just apply this patch test_tooltip.patch

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #229044 (closed)

Edited by Enrique Alcántara

Merge request reports

Loading