deephaven / web-client-ui

Deephaven Web Client UI
Apache License 2.0
28 stars 30 forks source link

fix: Console does not scroll to bottom when code run from notebook #2114

Closed mattrunyon closed 1 month ago

mattrunyon commented 1 month ago

Noticed running code from a notebook wasn't scrolling to the bottom.

I didn't catch this behavior changing in #2076, but looks like the componentDidUpdate doesn't necessarily wait until after the paint or the ref isn't updated for some reason. So the scrollHeight can be the old value and then scrollTo (or scrollTop = scrollHeight) triggers the scroll event which sets isStuckToBottom to false. Not exactly sure

The requestAnimationFrame call seems to be working. The other option I thought of what ignoring programmatic scrolling, but the only way I saw to do that was to set some state in the class and then check it in the scroll handler and reset it after. There's nothing about the event that indicates if it was triggered via scrollTo.

There were some weird update values when I was logging this. Like the height would be 1900 for 3 renders, then 1700, then 1900 again. Guessing it's due to rendering of the console buttons.

mattrunyon commented 1 month ago

Could even be OS dependent. I just noticed it when I was running chunks of code from a notebook that created tables