docs-v2/assets/styles/layouts
Jason Stirnaman ab8223d11e
fix(ui): fix Ask AI code control and add e2e tests (#6955)
* feat(ui): add Ask AI to code block controls menu

Add an "Ask AI" option to the code controls dropdown menu on all code
blocks. Uses data-ask-ai-query attribute if provided by the template,
otherwise builds a query from the code content. Delegates to the
existing Kapa widget integration via the ask-ai-open click handler.

* fix(ui): fix Ask AI code control and add e2e tests

## Summary

- Add "Ask AI" option to the code controls dropdown (three-dot menu) on all code blocks
- Uses `data-ask-ai-query` attribute from the template if available, otherwise builds a query from the code content
- Delegates to the existing Kapa widget via the `ask-ai-open` click handler contract
- Reorder menu items: Copy → Ask AI → Fill window

## Bug fix

Fix Ask AI button not opening the Kapa widget. jQuery `.trigger('click')`
doesn't dispatch native DOM events, so the native
`document.addEventListener` in ask-ai-trigger.js never received the click.
Switch to native `.click()` and remove `href="#"` to prevent scroll-to-top.

## Tests

Add Cypress e2e test suite (`code-controls.cy.js`) with 16 tests covering:
- Initialization: code blocks wrapped, controls appended, menu item order
- Toggle: open/close on click, close on outside click, independent menus
- Copy to clipboard: success lifecycle, revert after timeout
- Fullscreen: modal open/close, body scroll lock, placeholder restore
- Ask AI: Kapa modal opens, query built with code content (MutationObserver)

* fix(ui): apply icon spacing to all code control menu items

Move .cf-icon margin-right rule from .copy-code and .fullscreen-toggle
to the shared li level so it applies to all menu items including Ask AI.

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix(ui): add keyboard accessibility to code controls menu

Replace clickable <span> and <li> elements with proper <button> elements
and ARIA roles for keyboard and assistive-technology access:

- Toggle: <span> → <button> with aria-label and aria-expanded
- Menu items: <li> → <li role="none"><button role="menuitem">
- Menu: <ul> gets role="menu"
- SCSS: add :focus-visible styles, reset button defaults
- JS: toggle handler updates aria-expanded on open/close

Also fix tests to match actual behavior:
- Remove bogus "close other menus" test that manually closed first menu
  before opening second (tested nothing)
- Remove duplicate "close on re-click" test (same as outside-click)
- Add "keep menu open when copy is clicked" (stopPropagation behavior)
- Add accessibility markup validation test

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-16 21:05:47 -05:00
..
article feat(ent3): add experimental badge for --use-pacha-tree (#6857) 2026-02-23 14:58:35 -06:00
modals InfluxDB Clustered documentation (#5126) 2023-09-06 06:21:47 -06:00
_algolia-search-overrides.scss hotfix: fix search input background when switching themes, closes #3799 2022-02-22 08:51:59 -07:00
_api-overrides.scss hotfix: fix mermaid.js diagrams, closes #4640 2022-11-16 14:21:02 -07:00
_article.scss feat(caches): update explorer docs with information about querying LVCs and DVCs (#6437) 2025-10-01 09:43:16 -06:00
_code-controls.scss fix(ui): fix Ask AI code control and add e2e tests (#6955) 2026-03-16 21:05:47 -05:00
_content-wrapper.scss finalized new homepage, resolves #1327 2020-09-02 12:16:00 -06:00
_datetime.scss Merge pull request #6079 from influxdata/chore-js-refactor-footer-scripts-modules 2025-06-09 14:40:37 -05:00
_error-page.scss InfluxDB 2.1 (#3367) 2021-11-08 09:48:11 -08:00
_feature-callouts.scss Consolidate sessions cookies and implement APIs to manage each (#5319) 2024-02-15 07:45:45 -07:00
_footer-widgets.scss Initial Kapa.ai chat integration. 2025-02-03 08:31:55 -06:00
_global.scss hotfix: fix small styling issues with top nav, modals, and feature callouts 2023-03-09 15:22:50 -07:00
_homepage.scss update: start explorer docs (#6102) 2025-05-29 18:29:16 -05:00
_inline-icons.scss InfluxDB get started (#4628) 2022-11-21 15:44:14 -07:00
_landing.scss Feature: Generate documentation in LLM-friendly Markdown (#6555) 2025-12-01 12:32:28 -06:00
_loading-spinner.scss Collect user feedback per page and restructure modals (#4014) 2022-05-13 16:35:01 -06:00
_modals.scss feat(influxdb): Version detector shortcode triggers a modal 2025-09-30 19:01:21 -05:00
_notifications.scss chore(docker): add notice about docker latest tag changes (#6435) 2025-10-01 08:03:08 -06:00
_sidebar-toggle.scss Coveo search links in the search UI (#3534) 2022-01-05 15:58:21 -07:00
_sidebar.scss feat(feature-boards): embed product feature boards in the docs (#6767) 2026-01-30 12:41:02 -07:00
_syntax-highlighting.scss Add support for GitHub style alerts (#5667) 2024-11-07 14:54:01 -07:00
_top-nav.scss feat(feature-boards): embed product feature boards in the docs (#6767) 2026-01-30 12:41:02 -07:00
_v1-overrides.scss Chronograf 1.9.0 (#2788) 2021-06-28 11:20:09 -06:00
_v3-wayfinding.scss Update v3 wayfinding modal (#5230) 2023-11-13 10:19:38 -07:00