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

Save expanded/collapsed state of segment groups #7928

Merged
merged 21 commits into from
Jul 24, 2024

Conversation

dieknolle3333
Copy link
Contributor

@dieknolle3333 dieknolle3333 commented Jul 17, 2024

Steps to test:

  • Open an annotation and go to segments tab. Create a group hierarchy (around three levels min) with some segments in each group.
  • Expand and collapse some groups, remember state.
  • Change to another tab and back. The state (groups expanded/collapsed) should be the same.
  • Reload the page. The state should still be the same
  • Test that old behavior is still working. Expanding and collapsing via arrow icon, expansion/collapse of all subgroups etc.

TODOs:

  • fix bug that expand children on root doesnt work after collapsing all subgroups

Issues:


(Please delete unneeded items, merge only when none are left open)

@dieknolle3333 dieknolle3333 marked this pull request as ready for review July 18, 2024 15:11
Copy link
Member

@fm3 fm3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend LGTM :) Testing worked nicely, backwards compatibility looks OK. As mentioned in Slack, the root group gets expanded again after reload, raising the question if it needs to be collapsible in the first place, but I’d say that’s not particularly important.

Please add a changelog entry :)

@dieknolle3333
Copy link
Contributor Author

dieknolle3333 commented Jul 18, 2024

I am not 100% sure, but I feel like expanding and collapsing got slower. I compared it to webknossos.org and I am still not super sure. But I wanted to mention it. Maybe there is a faster way to get the current expanded/collapsed group state from the segmentGroups? @philippotto

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool :) I left some feedback.

Store.dispatch(setSegmentGroupsAction(newGroups, this.props.visibleSegmentationLayer?.name));
};

collapseGroups = (groupsToCollapse: Key[]) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesn't this method handle the root group like the expandGroups method does? is it not necessary in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also: the two methods differ in their semantics of the parameters. for collapseGroups I understand it so that the referenced groups will be collapsed (and other collapsed groups will stay as before). for expandGroups, it seems like only the referenced groups should be expanded (and all the others should not be expanded). can this be unified?

Copy link
Contributor Author

@dieknolle3333 dieknolle3333 Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, the methods differ. this is because expandGroups is called by the Tree component and the expandSubgroups menu entry. collapseGroups is only called to collapse the children. The tree component also calls this if groups are collapsed, by removing the collapsed groups trees from the list. Thus isExpanded has to be set to false for these groups. Other than that, the root group is handled differently because on expand all subgroups the parent group is expanded if it was collapsed before. This is different for expanded groups, their state doesn't change if their children are collapsed.
I could use three methods: one for the Tree component and two for "collapse/expand subgroups". And then comment what I said above. Do you think that this might be a good solution? @philippotto

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I understand. two methods are fine then. I'd the expandGroups method to setExpandedGroups. That way, it should be clearer that the semantics is different to collapseGroups.

Other than that, the root group is handled differently because on expand all subgroups the parent group is expanded if it was collapsed before. This is different for expanded groups, their state doesn't change if their children are collapsed.

A comment for that would be good, yes 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong: this code snippet enables an update of the root group itself. the state update (isRootGroupExpanded) triggers an update of the root group object which is separate because the rootgroup is only stored in the component.

@philippotto philippotto changed the base branch from master to collapse-all-segment-group-children July 22, 2024 09:35
@philippotto philippotto changed the base branch from collapse-all-segment-group-children to master July 22, 2024 09:36
@philippotto philippotto changed the base branch from master to collapse-all-segment-group-children July 22, 2024 09:36
@philippotto
Copy link
Member

Only after reviewing, I noticed that this PR is based on #7911. I manually changed the base of the PR now. In the future, you should do this when creating the PR :) Can be done here:

image

Otherwise, all the changes of the first PR will also be shown here in the diff, too.

@dieknolle3333
Copy link
Contributor Author

Otherwise, all the changes of the first PR will also be shown here in the diff, too.

I see. So I set it to the base branch although I will merge it into master eventually. And then I can probably set it to master once the base branch is merged and I have rebased the commits of this PR, right?

@philippotto
Copy link
Member

I see. So I set it to the base branch although I will merge it into master eventually. And then I can probably set it to master once the base branch is merged and I have rebased the commits of this PR, right?

Exactly! Even better, GitHub will automatically set the base to "master" once the first PR is merged.

Base automatically changed from collapse-all-segment-group-children to master July 23, 2024 12:08
@dieknolle3333 dieknolle3333 force-pushed the focus-segment-in-collapsed-group branch from 939ab91 to e32ba49 Compare July 23, 2024 14:18
@dieknolle3333
Copy link
Contributor Author

dieknolle3333 commented Jul 23, 2024

@philippotto because of the different base branch I rebased my changes on master. The numbers of the diff are slightly different (used to be +170, -12). I hope that is somewhat expected. It still works well, so I hope the rebase was fine.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🎉 Performance feels still a bit laggy, but this is unrelated to this PR. Let's merge it and iterate later :)

@dieknolle3333 dieknolle3333 enabled auto-merge (squash) July 24, 2024 13:50
@dieknolle3333
Copy link
Contributor Author

Great 🎉 Performance feels still a bit laggy, but this is unrelated to this PR. Let's merge it and iterate later :)

Thank you for the review! I feel like the skeleton tab made some different decisions regarding the removal of "unnecessary" options, by just showing them and saving some cost there. Maybe that is among the things to look out for.

@dieknolle3333 dieknolle3333 merged commit c996ec2 into master Jul 24, 2024
2 checks passed
@dieknolle3333 dieknolle3333 deleted the focus-segment-in-collapsed-group branch July 24, 2024 14:11
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.

Reloading the page should retain collapsed-state of (segment) groups
4 participants