Skip to content

Commit db95eab

Browse files
committed
fix(web): keep the model quick-switch menu inside the viewport
The menu opens above its pill with a 160px minimum height, so a pill near the top of the viewport produced a menu that reached past the viewport edge and could not be scrolled to. Clamp the height to the space that is actually available; the 360px cap is unchanged.
1 parent 7dd68cb commit db95eab

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Keep the web model quick-switch menu inside the viewport when the composer sits near the top of the window.

apps/pythinker-web/src/components/Composer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ function toggleDropdown(): void {
749749
if (dropdownOpen.value) {
750750
const rect = modelPillRef.value?.getBoundingClientRect();
751751
modelDropdownStyle.value = rect
752-
? { maxHeight: `${Math.min(360, Math.max(160, rect.top - 4 - 12))}px` }
752+
? { maxHeight: `${Math.min(360, Math.max(0, rect.top - 4 - 12))}px` }
753753
: {};
754754
permDropdownOpen.value = false;
755755
document.addEventListener('click', onDocClick, true);

apps/pythinker-web/test/composer.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,11 @@ describe('Composer model dropdown', () => {
408408
const pill = wrapper.get('.model-pill');
409409
const rect = vi.spyOn(pill.element, 'getBoundingClientRect');
410410

411+
// A pill near the top of the viewport used to get a 160px menu that reached
412+
// above the viewport edge, so its upper entries could not be scrolled to.
411413
rect.mockReturnValue({ top: 20 } as DOMRect);
412414
await pill.trigger('click');
413-
expect(wrapper.get('.model-dropdown').element.style.maxHeight).toBe('160px');
415+
expect(wrapper.get('.model-dropdown').element.style.maxHeight).toBe('4px');
414416

415417
rect.mockReturnValue({ top: 300 } as DOMRect);
416418
await pill.trigger('click');

0 commit comments

Comments
 (0)