Implement tooltip API for the following actions
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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)