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

✨ (explorer) make selected entity travel on top #3393

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Mar 22, 2024

after.mov

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sophiamersmann and the rest of your teammates on Graphite Graphite

@sophiamersmann sophiamersmann marked this pull request as ready for review March 22, 2024 11:20
Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Disclaimer: I have spent way too much time looking at this PR, and trying to find any other clever way to find out which element is currently animated because of a selection change.

But I couldn't really find a clever way that also works well.
My best attempt, I think, was to maintain an animatingEntityNames set, and all these entries would then get an isAnimating prop set. I think that works quite well in the case where a single entry is animated, but not for the case when multiple ones are at the same time - which is a rare occurrence at the spring settings we use, anyway.

Anyway, I don't really know where this review is going. In my mind, this change is almost a bit too complicated for something that doesn't work perfectly, and that is hard to spot anyway. But, as outlined above, I can't really provide too much of a feedback as to what to do differently :/

opacity
onStart={(element, decisionData) => {
if (isFlipping(decisionData)) {
element.classList.add("animating")
Copy link
Member

Choose a reason for hiding this comment

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

Setting the class this way is, sadly, a bit fickle:
The classname will be reset the next time the React tree renders - which is, for example, the case as soon as you hover over any other PickerEntry.

An alternative could be to set isAnimating as a React state, or alternatively to pass it in as another prop from the parent somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

@sophiamersmann sophiamersmann force-pushed the explorer-entity-picker branch 2 times, most recently from 64d09a4 to ce05710 Compare March 25, 2024 10:14
@sophiamersmann
Copy link
Member Author

Maybe like this? The code is not much nicer, but at least it works as expected. "Most recently selected entity name" is a bit of a weird concept, and the most recently selected entity keeping its higher z-index even after the animation has stopped is not ideal. But it also doesn't hurt?

The reason I'm working on this is that I'm evaluating whether to use the react-flip-toolkit library for Grapher's entity selector. This is a bug that I wouldn't want the new entity selector to have. If there is no good solution here, then I would start looking into other 3rd party libraries that provide similar behaviour.

Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Yes, I think this works well now.
Obviously it doesn't work well in the case when multiple entities are being selected at the same time - but as stated above, that is almost impossible to do with the current spring settings.

@sophiamersmann sophiamersmann mentioned this pull request Mar 28, 2024
11 tasks
@sophiamersmann
Copy link
Member Author

Coming back to it after a short break, this PR makes me a bit sad :(

I think I'll leave it open while working on the new entity selector. Maybe working with the reach-flip-toolkit library a bit more will show us another way...

If anything else comes to your mind regarding this, let me know :)

@sophiamersmann sophiamersmann force-pushed the explorer-entity-picker branch from ce05710 to 2f92bdb Compare April 11, 2024 14:43
@sophiamersmann sophiamersmann force-pushed the explorer-entity-picker branch from 2f92bdb to db4aa7e Compare April 11, 2024 14:59
@sophiamersmann sophiamersmann merged commit c10330d into master Apr 16, 2024
30 of 32 checks passed
@sophiamersmann sophiamersmann deleted the explorer-entity-picker branch April 16, 2024 08:54
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.

2 participants