-
Notifications
You must be signed in to change notification settings - Fork 124
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
Fix missing frame when animating thought up/down #2765
Fix missing frame when animating thought up/down #2765
Conversation
10436dd
to
69df685
Compare
@raineorshine, could you please re-run the failed test? It seems like a pipeline issue to me. |
Thanks! Can you confirm that you tested We should also do a performance benchmark before/after since this potentially introduces a lot of state changes during a critical rendering phase. |
I tested preventAutoscroll by simulating an up/down movement animation and then focusing on one of the subthoughts. You can view the screen recording here: ios.mp4I've confirmed that the flag resets once the transition is complete. You can check the relevant code here: em/src/components/TreeNodeAnimation.tsx Lines 33 to 38 in 54ff6d7
Additionally, I’ve optimized the code by using em/src/components/TreeNodeAnimation.tsx Line 24 in 54ff6d7
Previously, using |
That sounds great. I'll let @trevinhofmann review and test first, but looking forward to trying it out! |
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.
Thank you, @zukilover! This appears to resolve the animation for thoughts moved down:
Screen.Recording.2025-01-15.at.5.48.49.AM.mov
I've also tested on mobile (iOS Safari), and the animations work there as well.
I just have one question regarding the snapshots, otherwise this looks good to me.
...ppeteer/__tests__/__image_snapshots__/render-thoughts/font-size-18-default-superscript-1.png
Show resolved
Hide resolved
Thank you both for your work on this tricky issue. I was finally able to reproduce the layout shift on Given this, I will tentatively say that the layout issue is not a regression caused by this PR and can be safely ignored. Needless to say, this does not evoke confidence in the puppeteer tests. But I think that is out of scope for this issue, and can be addressed in the new issue I created. Now, considering the current approach. I do have concerns with the complexity and potential performance impact of this change. It involves All of this seems to center around the Question: Is the Note that there are two different autoscroll scenarios to be aware of. I regret that they use the same name, as this ambiguity only confuses the matter:
Next steps:
|
@raineorshine, here's my conclusion after comparing the behavior of the main branch with this PR: I tested it on iOS Safari, and it’s clear that if the purpose of adding the hack-ish The other notable difference is that, in the main branch, adding a subthought on mobile causes the virtual keyboard to cover the editable. However, in this PR, I can focus on the editable without it being obscured by the keyboard. Main branch: main.mp4This PR: pr.mp4I’m wondering if we should move forward with this PR by removing the style entirely? |
Thanks for testing it out. The videos look close to me, though it's a bit hard to compare frame by frame. It even appears that the preventAutoscroll utility (2) may be overriding the preventAutoscroll style (1). Could you try disabling the utility and seeing if the tutorial still autoscrolls? I just want to establish firmly that the style does not have any effect and is no longer needed. @trevinhofmann can also validate. Thanks so much! |
I did some quick testing on iOS Safari to compare mainaa-main.mp4this pull requestaa-pr.mp4this pull request, with preventAutoScroll style disabledaa-style.mp4this pull request, with preventAutoScroll utility disabledaa-utility.mp4It seems that disabling the |
Thanks @trevinhofmann! I think we're good to remove the While existing code is usually there for a reason, this is a good reminder that it doesn't hurt to test those base assumptions. It's a rare exception, nevertheless, and I'm glad we were cautious. Thanks @zukilover for all your work. |
Thoroughly tested and does not appear to cause any regressions. For a complete discussion, see #2765 (comment).
This PR fixes the missing frame issue at #2498 , which occurs when the editable
preventAutoscroll
class is applied, causing the thought to render with zero opacity:em/src/components/Editable.tsx
Lines 595 to 597 in 13f92af
The solution ensures that the
preventAutoscroll
class is omitted during they
transition of the tree node. To achieve this, I refactored they
animation intoTreeNodeAnimation.tsx
and introduced a newisAnimating
flag. Since this flag needs to be passed down through multiple layers (5 levels fromLayoutTree
toEditable
), I implemented a React context to manage the state more effectively.