cybersemics / em

A beautiful, minimalistic note-taking app for personal sensemaking.
Other
258 stars 88 forks source link

Handle empty context view height #2076

Closed finkef closed 1 week ago

finkef commented 1 week ago

Fixes #1826.

This PR handles a thought's height not accounting for the empty context view message. Since we want to trigger the update using a selector effect, we need delay the update until after the tree is done rendering. requestAnimationFrame seems to be the best and most idiomatic way of achieving this without using overly convoluted combinations of useSelectorEffect and useRef, etc.

raineorshine commented 1 week ago

I just had another thought. You might also be able to the context view state as a local variable with useSelector, and then add that variable to the useEffect hook that is already in place to call updateSize. Then you wouldn't need rAF.

finkef commented 1 week ago

I just had another thought. You might also be able to the context view state as a local variable with useSelector, and then add that variable to the useEffect hook that is already in place to call updateSize. Then you wouldn't need rAF.

You're right, that works well in this case and removes the need for the delayed function version. Updated. 👍

raineorshine commented 1 week ago

Great, I'm glad that worked.

I will be merging into the https://github.com/cybersemics/em/tree/table-fabian branch during your trial period. I recommend using that as your upstream rather than main.

raineorshine commented 1 week ago

I will be merging into the ~table-fabian~ branch during your trial period. I recommend using that as your upstream rather than main.

Sorry, I meant to name the branch https://github.com/cybersemics/em/tree/linewrap-fabian. Renamed.