Skip to content

fix(GlTooltip): Reduce component boundary padding

Mark Florian requested to merge 2208-fix-tooltip-component-boundary-padding into main

What does this MR do?

fix(GlTooltip): Reduce component boundary padding

The tooltip component has a default boundary padding of 50, whereas the directive has a default boundary padding of 5. There's no obvious reason for this difference, and it appears to be a bug upstream: https://github.com/bootstrap-vue/bootstrap-vue/issues/6507.

This bug means that tooltips placed on elements near the configured boundary (e.g., the viewport) will render unnecessarily offset, usually so much that the arrow on the tooltip is disconnected from it.

Screenshots or screen recordings

These screenshots are created using this patch:

Show patch
diff --git a/src/components/base/tooltip/tooltip.stories.js b/src/components/base/tooltip/tooltip.stories.js
index c26cd4713..3ec8b8362 100644
--- a/src/components/base/tooltip/tooltip.stories.js
+++ b/src/components/base/tooltip/tooltip.stories.js
@@ -25,6 +25,33 @@ function makeTooltip(modifier = '') {
   };
 }
 
+export const BoundaryPadding = (args, argTypes) => ({
+  components: { GlTooltip, GlButton },
+  directives: {
+    GlTooltip: GlTooltipDirective,
+  },
+  props: Object.keys(argTypes),
+  template: `
+      <div class="gl-display-flex gl-justify-content-space-between gl-w-half">
+        <gl-button id="tooltip-target-1">
+          Component tooltip
+        </gl-button>
+        <gl-tooltip target="tooltip-target-1" triggers="manual" placement="right" show>
+          I am tooltip <b>component</b>!
+        </gl-tooltip>
+        <gl-button v-gl-tooltip.right="'I am a tooltip directive!'" id="tooltip-target-2">
+          Directive tooltip
+        </gl-button>
+      </div>
+    </div>
+  `,
+  mounted() {
+    this.$nextTick(() => {
+      this.$root.$emit('bv::show::tooltip', 'tooltip-target-2');
+    });
+  },
+});
+
 export const TopDefault = (args, argTypes) => ({
   ...makeTooltip(),
   props: Object.keys(argTypes),
Before After
before_tt after_tt

Integration merge requests

Does this MR meet the acceptance criteria?

This checklist encourages the authors, reviewers, and maintainers of merge requests (MRs) to confirm changes were analyzed for conformity with the project's guidelines, security and accessibility.

Toggle the acceptance checklist

Conformity

  • Code review guidelines.
  • GitLab UI's contributing guidelines.
  • If it changes a Pajamas-compliant component's look & feel, the MR has been reviewed by a UX designer.
  • If it changes GitLab UI's documentation guidelines, the MR has been reviewed by a Technical Writer.
  • If the MR changes a component's API, integration MR(s) have been opened (see integration merge requests above).
  • Added the ~"component:*" label(s) if applicable.

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
  • Security reports checked/validated by a reviewer from the AppSec team

Accessibility

If this MR adds or modifies a component, take a few moments to review the following:

  • All actions and functionality can be done with a keyboard.
  • Links, buttons, and controls have a visible focus state.
  • All content is presented in text or with a text equivalent. For example, alt text for SVG, or aria-label for icons that have meaning or perform actions.
  • Changes in a component’s state are announced by a screen reader. For example, changing aria-expanded="false" to aria-expanded="true" when an accordion is expanded.
  • Color combinations have sufficient contrast.

Closes #2208 (closed)

Edited by Mark Florian

Merge request reports