Skip to content

refactor(dify-ui): render ContextMenu story trigger as a semantic area#38420

Merged
lyzno1 merged 3 commits into
mainfrom
copilot/context-menu-trigger-update
Jul 5, 2026
Merged

refactor(dify-ui): render ContextMenu story trigger as a semantic area#38420
lyzno1 merged 3 commits into
mainfrom
copilot/context-menu-trigger-update

Conversation

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Per Base UI docs, ContextMenu.Trigger is semantically an area (right-click / long-press) that renders a <div> by default — unlike Menu.Trigger, which is a click-activated button. The ContextMenu story wrongly overrode the trigger with render={<button type="button" />}, giving it incorrect button semantics (implicit role="button", keyboard activation, extra style reset burden) that mismatch a right-click region.

Changes

  • packages/dify-ui/src/context-menu/index.stories.tsx: TriggerArea now applies styling via className directly on ContextMenuTrigger, letting it render its default <div> area instead of a <button>. Visual appearance (size, border, background, focus ring) is preserved; only the button element and type="button" are removed.
<ContextMenuTrigger
  aria-label="context menu trigger area"
  className="flex h-44 w-80 items-center justify-center rounded-xl border ..."
>
  {label}
</ContextMenuTrigger>

Story-only, non-behavioral change; existing tests already relied on the default <div> rendering.

Screenshots

Before After
Trigger rendered as <button> Trigger rendered as default <div> area

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

From Copilot

Copilot finished work on behalf of lyzno1 July 5, 2026 01:20
Copilot AI requested a review from lyzno1 July 5, 2026 01:20
@lyzno1 lyzno1 changed the title Render ContextMenu story trigger as a semantic area, not a button refactor(dify-ui): render ContextMenu story trigger as a semantic area Jul 5, 2026
Copilot finished work on behalf of lyzno1 July 5, 2026 01:23
@lyzno1 lyzno1 marked this pull request as ready for review July 5, 2026 01:30
@lyzno1 lyzno1 enabled auto-merge July 5, 2026 01:30
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Jul 5, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label Jul 5, 2026
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.30%. Comparing base (f755830) to head (f1983d6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #38420   +/-   ##
=======================================
  Coverage   85.30%   85.30%           
=======================================
  Files        4995     4995           
  Lines      264326   264326           
  Branches    50141    50141           
=======================================
  Hits       225479   225479           
  Misses      34429    34429           
  Partials     4418     4418           
Flag Coverage Δ
dify-ui 94.75% <ø> (ø)
web 84.86% <ø> (ø)

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

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lyzno1 lyzno1 added this pull request to the merge queue Jul 5, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 5, 2026
Merged via the queue into main with commit f8d4761 Jul 5, 2026
38 checks passed
@lyzno1 lyzno1 deleted the copilot/context-menu-trigger-update branch July 5, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:S This PR changes 10-29 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.

3 participants