New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track live selection #9924
Track live selection #9924
Conversation
// === Selected nodes validity === | ||
elementDeleted: (id: T) => { | ||
if (selected.delete(id)) deleted.add(id) | ||
}, | ||
elementUndeleted: (id: T) => { | ||
if (deleted.delete(id)) selected.add(id) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We said during refinement, that we should have the actually selected
field being a computed
value which filters out selected
which are not in graphDb.nodeIdToNode.keys
. The keyset is reactive, so any change affecting our selection would make the computed to recompute.
I prefer the computed
solution: it's maybe a bit farther from being optimal, but much simpler: wouldn't need to manually inform selection that a node was added/deleted.
export function* filter<T>(iter: Iterable<T>, include: (value: T) => boolean): Iterable<T> { | ||
for (const value of iter) if (include(value)) yield value | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is lib0/iteratorFilter
perhaps we could just reexport it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That takes an iterator
, which is less convenient.
const hoveredNode = ref<NodeId>() | ||
const hoveredElement = ref<Element>() | ||
let initiallySelected = new Set<T>() | ||
const rawSelected = shallowReactive(new Set<T>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw
is a bit unclear term, but I cannot think of any other name. At least, a comment explaining what is rawness
here would help future readers.
Pull Request Description
Remove components from the selection when they cease to be present in the displayed graph; when they are removed for this reason, they will be added back to the selection if they are recreated and no intervening selection change has occurred.
Fixes #9903.
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.