Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ui): position the combobox panel from the edge it opens toward

rubenluetke10-beepc7795419306c
diff --git a/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx b/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
index 83e087b360..c2e810284f 100644
--- a/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
@@ -113,3 +113,33 @@ describe("Combobox non-search listbox accessibility", () => {
expect(onChange).toHaveBeenCalledWith("english");
});
});
+
+describe("Combobox panel placement", () => {
+ it("opens downwards under the trigger when there is room", async () => {
+ vi.spyOn(window, "innerHeight", "get").mockReturnValue(900);
+ vi.spyOn(HTMLButtonElement.prototype, "getBoundingClientRect").mockReturnValue({
+ top: 100, bottom: 128, left: 40, right: 240, width: 200, height: 28, x: 40, y: 100, toJSON: () => ({}),
+ } as DOMRect);
+ render(<Combobox value="alpha" groups={GROUPS} onChange={() => {}} ariaLabel="Down" testId="down" />);
+ fireEvent.click(screen.getByTestId("down"));
+ const panel = await screen.findByTestId("down-panel");
+ expect(panel.style.top).toBe("134px");
+ expect(panel.style.bottom).toBe("");
+ });
+
+ it("hangs its bottom edge over a trigger near the viewport floor instead of assuming a height", async () => {
+ // A composer pill 60px above the floor: below is cramped, above is roomy.
+ vi.spyOn(window, "innerHeight", "get").mockReturnValue(900);
+ vi.spyOn(HTMLButtonElement.prototype, "getBoundingClientRect").mockReturnValue({
+ top: 812, bottom: 840, left: 40, right: 240, width: 200, height: 28, x: 40, y: 812, toJSON: () => ({}),
+ } as DOMRect);
+ render(<Combobox value="alpha" groups={GROUPS} onChange={() => {}} ariaLabel="Up" testId="up" />);
+ fireEvent.click(screen.getByTestId("up"));
+ const panel = await screen.findByTestId("up-panel");
+ // bottom = innerHeight - trigger.top + gap: the list grows upwards from
+ // the pill, however short it is — no top computed from MAX_PANEL_HEIGHT.
+ expect(panel.style.bottom).toBe("94px");
+ expect(panel.style.top).toBe("");
+ expect(parseInt(panel.style.maxHeight, 10)).toBeGreaterThanOrEqual(160);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/ui/combobox.tsx b/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
index ceef1494fa..f235781566 100644
--- a/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
+++ b/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
@@ -107,7 +107,15 @@ function defaultMatches(option: ComboboxOption, query: string): boolean {
interface PanelPosition {
left: number;
- top: number;
+ /** Set when the panel opens downwards: its top edge sits under the trigger. */
+ top?: number;
+ /**
+ * Set when the panel opens upwards: its BOTTOM edge sits over the trigger
+ * (a viewport `bottom`, so the panel grows up from the trigger whatever its
+ * real height). Positioning the top edge from an assumed height left a short
+ * list floating high above the trigger on first open.
+ */
+ bottom?: number;
width: number;
maxHeight: number;
}
@@ -231,8 +239,11 @@ export function Combobox({
Math.max(VIEWPORT_MARGIN, rect.left),
Math.max(VIEWPORT_MARGIN, window.innerWidth - width - VIEWPORT_MARGIN),
);
- const top = flipUp ? rect.top - maxHeight - 6 : rect.bottom + 6;
- setPosition({ left, top, width, maxHeight });
+ setPosition(
+ flipUp
+ ? { left, bottom: window.innerHeight - rect.top + 6, width, maxHeight }
+ : { left, top: rect.bottom + 6, width, maxHeight },
+ );
}, []);
useLayoutEffect(() => {
@@ -420,6 +431,7 @@ export function Combobox({
style={{
left: position.left,
top: position.top,
+ bottom: position.bottom,
width: position.width,
maxHeight: position.maxHeight,
}}