Warn in development when GlTooltip contains interactive content or can't be opened with the keyboard

Problem

Tooltips must not contain interactive content, because keyboard and screen reader users can't reach anything inside them (Pajamas: Tooltip – When not to use, WCAG 2.1.1). We added an ESLint rule for this (@gitlab/vue-no-interactive-content-in-tooltip, gitlab-org/frontend/eslint-plugin!193 (merged)), but static analysis has limits:

  • It only knows a fixed list of tag names, so it misses consumer components that render links or buttons.
  • It can't resolve computed slot content or v-gl-tooltip.html titles built at runtime.
  • It only runs in projects that use the ESLint plugin.

An accessibility audit also found tooltips and popovers that keyboard users can't open at all. In some, the element that opens them can't receive focus. In others, the directive uses .hover without .focus. Lint can only partly detect these.

Idea from @pgascouvaillancourt in gitlab-org/frontend/eslint-plugin!193 (comment 3984749525).

Proposal

After the Popover API tooltip (!6294 (merged)) is merged, add development-only checks that use logWarning(), so they never run in tests or production:

  1. Interactive content: in GlTooltip mounted and updated, query this.$refs.tooltip for focusable elements (for example a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"]), [contenteditable]). Warn with a link to the Pajamas guidance and suggest GlPopover.
  2. HTML titles: in the tooltip engine, run the same check on the sanitized .html title before inserting it.
  3. Keyboard access (optional, could be a separate issue): warn when the resolved target isn't focusable, or when triggers doesn't include focus.

Why wait for !6294 (merged)

With the current Bootstrap-Vue tooltip, the content only renders into <body> when the tooltip opens, so mounted has nothing to inspect. In !6294 (merged), GlTooltip always renders its content in its own <div popover="manual">, and the engine owns the .html title path.

Open questions

  • Should Jest fail on these warnings in GitLab (for example through a stricter mode in tests), or should they stay development-only?
  • Once this ships, do we keep the ESLint rule or remove it (and close gitlab-org/frontend/eslint-plugin#99 (closed))?