Skip to content

Conversation

@lyw405
Copy link
Contributor

@lyw405 lyw405 commented Aug 20, 2025

🐛 Bug Fix

Description

修复了 brush-select 行为中 onSelect 回调的设计问题。原实现错误地要求 onSelect 回调必须返回修改后的选中元素状态,这与预期的通知回调语义不符。

Changes

  • onSelect 回调的返回类型从 Record<ID, State | State[]> 改为 void
  • 更新了回调调用方式,不再期望返回值
  • 修复了 linting 问题,将 states 变量改为 const

Before

onSelect?: (states: Record<ID, State | State[]>) => Record<ID, State | State[]>;

// 调用方式
if (isFunction(onSelect)) states = onSelect(states);

After

onSelect?: (states: Record<ID, State | State[]>) => void;

// 调用方式
if (isFunction(onSelect)) onSelect(states);

Impact

  • onSelect 现在作为纯通知回调,符合预期语义
  • ✅ 用户不再需要在回调中返回状态对象
  • ✅ 框选功能保持完全向后兼容
  • ✅ 修复了类型检查错误

Testing

  • 本地测试通过
  • 无 linting 错误
  • 类型检查通过

Fixes #7303

…ject to void

- Changed onSelect callback return type from Record<ID, State | State[]> to void
- Updated callback invocation to not expect return value
- Fixed linting issue by changing states variable to const
- Resolves issue where onSelect callback was incorrectly expected to return modified states

Fixes antvis#7303
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.

Summary of Changes

Hello @lyw405, 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!

此拉取请求修复了 brush-select 行为中 onSelect 回调的一个设计缺陷。原先的实现错误地要求 onSelect 回调返回修改后的选中元素状态,这与其作为通知回调的预期语义不符。现在,onSelect 回调被修改为不返回任何值(void),使其纯粹用于通知,并修复了相关的 linting 问题,确保了框选功能的向后兼容性。

Highlights

  • onSelect 回调签名变更: 将 onSelect 回调的返回类型从 Record<ID, State | State[]> 修改为 void,使其符合纯通知回调的语义。
  • 回调调用方式更新: 更新了 onSelect 回调的调用方式,不再期望其返回任何值。
  • 变量声明优化: 将 states 变量的声明从 let 修改为 const,以提高代码的不可变性和可读性。
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 修复了 brush-select 行为中 onSelect 回调的设计问题,将其返回类型从 Record<ID, State | State[]> 修改为 void,使其作为纯粹的通知回调,这符合预期。同时,调用方式也相应更新,不再接收其返回值。此外,PR 还修复了一个 linting 问题,将 states 变量声明从 let 改为 const,因为该变量并未被重新赋值。这些改动增强了代码的健壮性和可读性,设计也更加合理。代码修改正确,我没有发现任何问题。

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] brush-select 框选 使用onSelect方法报错

1 participant