Skip to content
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

Merged
merged 3 commits into from May 16, 2024
Merged

Track live selection #9924

merged 3 commits into from May 16, 2024

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented May 10, 2024

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:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

@kazcw kazcw added the CI: No changelog needed Do not require a changelog entry for this PR. label May 10, 2024
@kazcw kazcw self-assigned this May 10, 2024
Comment on lines 151 to 157
// === Selected nodes validity ===
elementDeleted: (id: T) => {
if (selected.delete(id)) deleted.add(id)
},
elementUndeleted: (id: T) => {
if (deleted.delete(id)) selected.add(id)
},
Copy link
Contributor

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.

app/gui2/src/stores/graph/graphDatabase.ts Outdated Show resolved Hide resolved
@kazcw kazcw closed this May 15, 2024
@kazcw kazcw reopened this May 15, 2024
@kazcw kazcw requested a review from farmaazon May 15, 2024 14:53
Comment on lines 30 to 33
export function* filter<T>(iter: Iterable<T>, include: (value: T) => boolean): Iterable<T> {
for (const value of iter) if (include(value)) yield value
}

Copy link
Contributor

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.

Copy link
Contributor Author

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>())
Copy link
Contributor

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.

@kazcw kazcw merged commit 8823a2a into develop May 16, 2024
36 checks passed
@kazcw kazcw deleted the wip/kw/live-selection branch May 16, 2024 13:24
vitvakatu pushed a commit that referenced this pull request May 17, 2024
* Track live selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The multi-component menu should disappear after the group button is clicked
2 participants