Skip to content

Commit 4d25843

Browse files
lyw405Aarebecca
andauthored
fix(brush-select): change onSelect callback return type from state object to void (#7348)
- 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 #7303 Co-authored-by: Aaron <[email protected]>
1 parent e8d95bc commit 4d25843

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/g6/src/behaviors/brush-select.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ export interface BrushSelectOptions extends BaseBehaviorOptions {
9090
*
9191
* <en/> Callback when brush select elements.
9292
* @param states - 选中的元素状态
93-
* @returns 选中的元素状态
9493
*/
95-
onSelect?: (states: Record<ID, State | State[]>) => Record<ID, State | State[]>;
94+
onSelect?: (states: Record<ID, State | State[]>) => void;
9695
}
9796
/**
9897
* <zh/> 框选一组元素
@@ -246,7 +245,7 @@ export class BrushSelect extends BaseBehavior<BrushSelectOptions> {
246245

247246
const selectedIds = this.selector(graph, points, enableElements);
248247

249-
let states: Record<ID, State | State[]> = {};
248+
const states: Record<ID, State | State[]> = {};
250249

251250
switch (mode) {
252251
case 'union':
@@ -274,7 +273,7 @@ export class BrushSelect extends BaseBehavior<BrushSelectOptions> {
274273
break;
275274
}
276275

277-
if (isFunction(onSelect)) states = onSelect(states);
276+
if (isFunction(onSelect)) onSelect(states);
278277

279278
graph.setElementState(states, this.options.animation);
280279
}

0 commit comments

Comments
 (0)