Skip to content

Commit

Permalink
fix: 馃悰 should unselect previous selected cell when single selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Aug 12, 2020
1 parent debe04b commit 49c3ca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/x6-example-features/src/pages/selection/index.tsx
Expand Up @@ -24,7 +24,7 @@ export default class Example extends React.Component {
selecting: {
enabled: true,
rubberband: true,
multiple: true,
multiple: false,
strict: true,
showNodeSelectionBox: true,
selectCellOnMoved: false,
Expand Down Expand Up @@ -91,6 +91,7 @@ export default class Example extends React.Component {
})

graph.select(a)
graph.select([b, c])
}

refContainer = (container: HTMLDivElement) => {
Expand Down
9 changes: 8 additions & 1 deletion packages/x6/src/graph/selection.ts
Expand Up @@ -106,7 +106,14 @@ export class SelectionManager extends Base {
cells: Cell | string | (Cell | string)[],
options: Collection.AddOptions = {},
) {
this.widget.select(this.getCells(cells), options)
let selected = this.getCells(cells)
if (!this.isMultiple() && selected.length > 0) {
this.clean()
if (selected.length > 1) {
selected = selected.slice(0, 1)
}
}
this.widget.select(selected, options)
return this
}

Expand Down

0 comments on commit 49c3ca7

Please sign in to comment.