Skip to content

Conversation

@XiaoMing-xmg666
Copy link
Collaborator

Feat: #7100
增加了drag-element trigger配置项,文档改动之后再提一个pr,效果如下
Kapture 2025-11-18 at 09 50 36

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @XiaoMing-xmg666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the drag-element behavior by introducing a new trigger configuration. This feature allows developers to define specific keyboard shortcuts that must be held down for an element to be draggable, providing more precise control over user interactions and preventing unintended dragging. The change integrates a new Shortcut utility to manage key press detection and updates the drag validation logic accordingly.

Highlights

  • New trigger configuration: Introduced a trigger option in DragElementOptions to specify keyboard shortcuts that must be pressed to activate the drag behavior for elements.
  • Shortcut integration: Integrated a Shortcut utility class to manage and detect specific key combinations, enabling the new trigger functionality.
  • Conditional dragging: The validate method within the DragElement behavior now checks the trigger configuration, ensuring that dragging is only enabled when the specified keys are actively pressed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 为 drag-element 行为增加了一个 trigger 配置项,允许用户通过组合键来触发拖拽,这是一个很好的功能增强。代码整体实现清晰,但在 isKeydown 方法的实现上,我发现一个问题可能会导致默认行为发生非预期的改变。当 trigger 未配置或为空数组时,拖拽应该总是允许的,但目前的实现会限制在没有任何按键按下的情况下才能拖拽。我已经在具体的代码行提出了修改建议以修正此问题。

@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.59%. Comparing base (62e2278) to head (0f06220).

Files with missing lines Patch % Lines
packages/g6/src/behaviors/drag-element.ts 87.50% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v5    #7497      +/-   ##
==========================================
- Coverage   95.60%   95.59%   -0.01%     
==========================================
  Files         188      188              
  Lines        9874     9881       +7     
  Branches     2083     2133      +50     
==========================================
+ Hits         9440     9446       +6     
- Misses        402      435      +33     
+ Partials       32        0      -32     
Flag Coverage Δ
g6 95.59% <87.50%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
packages/g6/src/behaviors/drag-element.ts 95.97% <87.50%> (-0.44%) ⬇️

... and 12 files with indirect coverage changes

🚀 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.

@XiaoMing-xmg666 XiaoMing-xmg666 force-pushed the feat/xmg/drag-element-trigger branch from 482db53 to b5a5d31 Compare November 18, 2025 02:07
@hustcc
Copy link
Member

hustcc commented Nov 18, 2025

文档和代码在一个 pr 里面完成吧,避免官网出现不一致。

@XiaoMing-xmg666
Copy link
Collaborator Author

文档和代码在一个 pr 里面完成吧,避免官网出现不一致。

@hustcc 加上了

@yvonneyx yvonneyx merged commit 0634925 into v5 Nov 21, 2025
2 checks passed
@yvonneyx yvonneyx deleted the feat/xmg/drag-element-trigger branch November 21, 2025 02:09
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.

5 participants