Skip to content

refactor(web): redesign Select component and migrate WorkplaceSelector#35293

Merged
lyzno1 merged 7 commits intomainfrom
cursor/redesign-select-component
Apr 16, 2026
Merged

refactor(web): redesign Select component and migrate WorkplaceSelector#35293
lyzno1 merged 7 commits intomainfrom
cursor/redesign-select-component

Conversation

@lyzno1
Copy link
Copy Markdown
Member

@lyzno1 lyzno1 commented Apr 16, 2026

Summary

Redesign the base/ui/select component to align with the project's established DropdownMenu pattern and shadcn/ui best practices, while migrating WorkplaceSelector from Headless UI to fix focus and semantics issues.

SelectTrigger

  • Remove clearable, onClear, loading, and variant (destructive) boolean props — these are business behaviors that don't belong in a base component (architecture-avoid-boolean-props)
  • Remove class-variance-authority dependency; use a simple Record for size variants
  • Keep size (small / regular / large) as a pure layout dimension
  • Consolidate trigger + content padding into trigger-level size classes
  • Built-in chevron icon via BaseSelect.Icon

SelectItem → pass-through (composition pattern)

  • Change from compound (ItemText + ItemIndicator baked in) to children pass-through, consistent with DropdownMenuItem
  • Export SelectItemText and SelectItemIndicator as composable styled wrappers, following DropdownMenuRadioItemIndicator pattern
  • Consumers compose: <SelectItem><SelectItemText>…</SelectItemText><SelectItemIndicator /></SelectItem>

SelectGroupLabel / SelectSeparator

  • Convert from bare re-exports to styled wrappers reusing menuGroupLabelClassName / menuSeparatorClassName from menu-shared.ts

WorkplaceSelector migration

  • Migrate from Headless UI Menu to base/ui/select, fixing the focus ring bug (outline-hidden + :focus-visible) and correcting menulistbox semantics
  • Override SelectTrigger defaults via className for the custom trigger appearance
  • Use SelectItem + SelectItemText composition for custom item layout (avatar + name + PlanBadge)

Callers

  • Update all 5 production callers to use the new SelectItemText + SelectItemIndicator composition API

Tests

  • Remove 8 clearable/loading/destructive tests
  • Add custom composition test (SelectItem without indicator)
  • All 18 tests pass

From Cursor

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Made with Cursor

- Remove clearable/loading/destructive boolean props from SelectTrigger,
  keeping only size variant with built-in chevron icon
- Change SelectItem from compound to pass-through, export SelectItemText
  and SelectItemIndicator as composable styled wrappers
- Add styled wrappers for SelectGroupLabel and SelectSeparator reusing
  menu-shared constants
- Migrate WorkplaceSelector from Headless UI Menu to Select, fixing
  focus ring bug and correcting menu→listbox semantics
- Update all 5 production callers to use new composition API

Made-with: Cursor
@github-actions github-actions Bot added the web This relates to changes on the web. label Apr 16, 2026
autofix-ci Bot and others added 3 commits April 16, 2026 04:00
…nt reuse

Rename `menu-shared.ts` → `overlay-shared.ts` and all exported constants
from `menu*ClassName` → `overlay*ClassName`. The shared styles are used
by Select, DropdownMenu, and ContextMenu — the "menu" prefix wrongly
implied they belong only to menu components.

Also add `min-w-(--anchor-width)` to SelectContent popup so the
dropdown width matches the trigger.

Made-with: Cursor
@lyzno1 lyzno1 marked this pull request as ready for review April 16, 2026 04:18
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. javascript Pull requests that update javascript code refactor labels Apr 16, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 16, 2026
@lyzno1 lyzno1 enabled auto-merge April 16, 2026 04:51
@lyzno1 lyzno1 added this pull request to the merge queue Apr 16, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 87.09677% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.10%. Comparing base (8baa864) to head (f7d8e3d).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
web/app/components/base/ui/select/index.tsx 55.55% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #35293   +/-   ##
=======================================
  Coverage   85.10%   85.10%           
=======================================
  Files        4399     4399           
  Lines      201355   201344   -11     
  Branches    38299    38292    -7     
=======================================
- Hits       171365   171356    -9     
+ Misses      26886    26884    -2     
  Partials     3104     3104           
Flag Coverage Δ
web 86.23% <87.09%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into main with commit b08665e Apr 16, 2026
33 checks passed
@lyzno1 lyzno1 deleted the cursor/redesign-select-component branch April 16, 2026 05:02
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
langgenius#35293)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
asukaminato0721 pushed a commit to asukaminato0721/dify that referenced this pull request Apr 24, 2026
langgenius#35293)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants