Skip to content

fix: keep model selector dropdown within viewport#1496

Open
Horizonll wants to merge 1 commit into
GCWing:mainfrom
Horizonll:main
Open

fix: keep model selector dropdown within viewport#1496
Horizonll wants to merge 1 commit into
GCWing:mainfrom
Horizonll:main

Conversation

@Horizonll

@Horizonll Horizonll commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix the model selector dropdown positioning so the model list stays fully visible when the app window is narrowed.

Fixes #1494

Type and Areas

Type:

bug fix / UI/UX

Areas:

web UI

Motivation / Impact

When the window width is reduced and the model selector is opened near the right edge, the dropdown was positioned from the trigger's left edge without clamping to the viewport. This could push the model list outside the visible window.

This change extracts the dropdown positioning calculation into a focused helper, clamps the dropdown width and horizontal position to the viewport, and lets narrow layouts shrink the menu while preserving text truncation.

Users can now open the model selector in narrow desktop windows without the list being cut off.

Verification

  • pnpm --dir src/web-ui run test:run src/flow_chat/components/modelSelectorDropdownPosition.test.ts
    • Passed: 1 file, 3 tests
  • pnpm run type-check:web
    • Passed
  • pnpm run build:web
    • Passed

Reviewer Notes

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Clamp the portal dropdown width and horizontal position to the viewport so the model list remains visible in narrow windows.

Verification:

- pnpm --dir src/web-ui run test:run src/flow_chat/components/modelSelectorDropdownPosition.test.ts

- pnpm run type-check:web

- pnpm run build:web
Copilot AI review requested due to automatic review settings July 10, 2026 06:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the Web UI model selector dropdown positioning in narrow windows by extracting a dedicated positioning helper that clamps the dropdown’s horizontal placement and width to the viewport, ensuring the menu stays fully visible near the right edge.

Changes:

  • Added getModelSelectorDropdownStyle helper to compute a fixed-position dropdown style with viewport clamping.
  • Updated ModelSelector to use the new helper for portal dropdown positioning on open/scroll/resize.
  • Adjusted dropdown SCSS to support shrinking layouts (including truncation/ellipsis behavior in the header and options).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/web-ui/src/flow_chat/components/modelSelectorDropdownPosition.ts New helper for dropdown width/left clamping and top/bottom placement style computation.
src/web-ui/src/flow_chat/components/modelSelectorDropdownPosition.test.ts Unit tests validating clamping behavior in narrow viewports and max-width scenarios.
src/web-ui/src/flow_chat/components/ModelSelector.tsx Switches runtime dropdown positioning logic to the new helper.
src/web-ui/src/flow_chat/components/ModelSelector.scss Updates dropdown sizing rules and improves truncation behavior for narrow widths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[Bug]: 窗口宽度调小后模型选择列表显示不完整

2 participants