Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): quote comment box stays in view for long code lines #22126

Closedfixfon(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/22126/headopened View on GitHub

Showing 3 changed files with 29 additions and 0 deletions.

x
0 of 3 viewed, 3 left
22 additions and 0 deletionsapps/web/src/components/chat/AssistantCitationChip.browser.test.tsxModified
View file
@@ -152,3 +152,25 @@
expect(textarea()).toBeNull();
});
});
+​
+describe("citation comment popup placement", () => {
+ it("opens inside the window when the cited line ends in a code block's horizontal overflow", async () => {
+ const pre = document.createElement("pre");
+ pre.style.cssText = "width: 120px; overflow-x: auto; white-space: pre; margin: 0";
+ pre.textContent = `${"x".repeat(400)}\ny`;
+ document.body.append(pre);
+ const range = document.createRange();
+ range.setStart(pre.firstChild!, 0);
+ range.setEnd(pre.firstChild!, 401);
+ sourceAnchor = { source: pre, range, viewport: document.body } as AssistantCitationSourceAnchor;
+ // The anchor is the selection's last rect: a narrow line-end rect past the window edge.
+ const rects = range.getClientRects();
+ expect(rects.item(rects.length - 1)!.left).toBeGreaterThan(window.innerWidth);
+​
+ await mount();
+​
+ const popup = document.querySelector('[data-slot="popover-popup"]')!.getBoundingClientRect();
+ expect(popup.left).toBeGreaterThanOrEqual(0);
+ expect(popup.right).toBeLessThanOrEqual(window.innerWidth);
+ });
+});
4 additions and 0 deletionsapps/web/src/components/chat/AssistantCitationChip.tsxModified
View file
@@ -175,6 +175,10 @@