Skip to content

fix(traffic): keep the tracking snippet inside its dialog - #1206

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/snippet-dialog-overflow
Oct 19, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/snippet-dialog-overflow

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

On AI Traffic, the tracking snippet's dialog (sources strip → Code / Install) let the script tag run past the dialog's edge.

DialogContent is a CSS grid. A grid item's min width is auto, so it can't shrink below its content. The snippet block holds one long, unbreakable <script …> line, and it widened the dialog past the screen.

  • The snippet block gets min-w-0, so it can be narrower than the tag.
  • The tag's <pre> wraps with whitespace-pre-wrap break-all instead of overflow-x-auto, so the whole tag is visible inside its box at any width.

The same block is used by the open banner, which now wraps the same way.

Related issue

None (user-reported: "the tracking code overflows its box").

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open AI Traffic and click Code (or Install) on the Tracking snippet card.
    • The tag wraps inside the grey box, and the dialog stays its own width (672 px at 1440).
  2. At a phone width (375 px), open it again.
    • The dialog fits the screen, the box doesn't scroll sideways (its scrollWidth equals its clientWidth), and the page doesn't scroll horizontally.
  3. The copy button still copies the whole tag.

Unit test: traffic/_snippet-code.test.tsx checks:

  • the full tag is shown;
  • the wrap and shrink classes, since jsdom has no layout;
  • copying.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/) — 0 errors, the 6 existing warnings
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn test (199 files, 1667 tests) and yarn build (placeholder env from ci.yml). Checked in the browser at 1440 px and at a phone width. Layout only; colors are unchanged.

🤖 Generated with Claude Code

The snippet's dialog lays its content out on a grid, and a grid item can't
be narrower than its content by default, so the one-line script tag
widened the dialog past the screen. The snippet block can now shrink
(min-w-0), and the tag wraps inside its box instead of scrolling, so the
whole tag shows at any width.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Small layout fix: the snippet tag widened the dialog because a grid item can't shrink below its content; the block now has min-w-0 and the tag wraps in its box. Checked at 1440 px and 375 px.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on main with #1205, #1207 and #1209: all web tests pass (1,673), including the new snippet dialog test, and typecheck is clean.

@gkhngyk
gkhngyk merged commit 5d99c5f into ansvisor:main Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants