Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): quote comment box stays on screen for long code lines #22149

MergedEtanHey(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/22149/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 59 additions and 1 deletion.

x
0 of 2 viewed, 2 left
50 additions and 0 deletionsapps/web/src/components/chat/AssistantCitationChip.browser.test.tsxModified
View file
@@ -6,8 +6,10 @@
} from "@t3tools/contracts";
import { useState, type ReactNode } from "react";
import { describe, expect, it, vi } from "vite-plus/test";
+import { userEvent } from "vite-plus/test/browser";
​
import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
+import "~/index.css";
import { act, render } from "../../../test/render";
​
const mocks = vi.hoisted(() => ({ observeSource: vi.fn(), dispose: vi.fn() }));
@@ -125,3 +127,51 @@
expect(textarea()).toBeNull();
});
});
+​
+describe("citation comment popup position", () => {
+ it("stays on screen when the cited text ends in a code block's hidden overflow", async () => {
+ using _source = setup();
+ const message = document.createElement("div");
+ message.className = "chat-markdown";
+ message.style.width = "240px";
+ const pre = document.createElement("pre");
+ const code = document.createElement("code");
+ // Highlighted code is split into token spans, so the range's last client rect
+ // covers only the final token, wholly inside the hidden overflow.
+ for (let index = 0; index < 40; index += 1) {
+ const token = document.createElement("span");
+ token.textContent = `token${index} `;