Skip to content

scrollable: promptly use displayHight on scroll#94

Merged
ali-abrar merged 2 commits intoreflex-frp:developfrom
Rosuavio:scroll-fix
Oct 19, 2025
Merged

scrollable: promptly use displayHight on scroll#94
ali-abrar merged 2 commits intoreflex-frp:developfrom
Rosuavio:scroll-fix

Conversation

@Rosuavio
Copy link
Contributor

During a scroll event, use the updated displayheight over the current displayHight when calculating the new scrollPosition.

Fix #93

@ali-abrar ali-abrar requested a review from cgibbard July 22, 2025 14:36
Copy link

@maralorn maralorn left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

I guess having scrollBy and scrollTo be triggered by displayheight was not in scope at time of writing. You could workaround this with a delay, but that might actually cause flickering.

AttachPromptly is always dangerous because of causality loops but I looked into it and since an update in displayHeight is always triggered by an external event from the terminal I guess we are fine.

I will leave this open a few more days so that anyone who actually knows the code base can intervene, but then I would merge this.

Copy link
Member

@alexfmpe alexfmpe left a comment

Choose a reason for hiding this comment

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

*promptly stuff is very rarely actually needed and tricky to ensure it won't later contribute to hard to debug causality loops. It is almost always the case that you can re-work things to make it unneeded. I don't even know when you do need it. Maybe critical performance stuff?

I'm not familiar with reflex-vty but here's what I gather from the diff:

If it makes a difference whether we use attachPromptlyDyn dh scrollTo or attach, it means updated dh triggers at the same time as scrollTo, so we should be able to grab the common ancestor of those two Events and "remember" info with it longer rather than trying to piece things together after the fact, which is what I think is happening here. The propagation of information split at some point into scrollTo and whatever was fed as input to foldDyn or holdDyn to make dh and at this point we try to re-assemble because we believe it fits.

I'd say it's the same pattern as parse, don't validate, only with FRP it's more of a remember, don't discover

@maralorn
Copy link

maralorn commented Aug 14, 2025

True, however a) as I said, a loop seems quite unlikely in this case b) the code where the "connection gets lost" is in the user code and not in the library. If we want to avoid this bug we should ideally provide an API so that the user can only get the desired behavior. (I.e. make it unlikely to run into this bug by accident.) I am not sure it is possible to design the API like that. It’s even unclear to me whether we can design the API such that the user can have the desired behavior.

So don’t get me wrong. I would love a better solution, but maybe we have to be pragmatic here.

ali-abrar and others added 2 commits August 15, 2025 04:10
During a scroll event, use the updated `displayheight` over the current
`displayHight` when calculating the new `scrollPosition`.

Fix reflex-frp#93
@alexfmpe
Copy link
Member

@ali-abrar thoughts?

@ali-abrar
Copy link
Member

@Rosuavio if I understand the issue correctly, the promptness is needed when the height is changing in the same frame, and the requested scroll position depends on the new height. Is that right?

@Rosuavio
Copy link
Contributor Author

@Rosuavio if I understand the issue correctly, the promptness is needed when the height is changing in the same frame, and the requested scroll position depends on the new height. Is that right?

Correct. Does #93, or my usage provide more context?

@ali-abrar
Copy link
Member

ali-abrar commented Sep 3, 2025

I think the change makes sense and, while I agree with the sentiment of @alexfmpe's comment, I worry that that would might make it rather difficult to actually use this widget.

Because reflex-vty uses behaviors much more than reflex-dom (which is designed around dynamics), we tend to have fewer issues with cycles.

@ali-abrar ali-abrar removed the request for review from cgibbard September 4, 2025 17:29
@ali-abrar
Copy link
Member

@alexfmpe are you ok with us moving forward here?

@alexfmpe alexfmpe self-requested a review September 4, 2025 21:10
@alexfmpe
Copy link
Member

alexfmpe commented Sep 4, 2025

I still think it'd be better to refactor to avoid the promptly, but I don't actually use reflex-vty so I'll defer to those that do

@Rosuavio
Copy link
Contributor Author

Rosuavio commented Sep 4, 2025

I still think it'd be better to refactor to avoid the promptly

That is something than can be done another time (after this merges) without much aditional breakage, correct?

@maralorn
Copy link

maralorn commented Sep 5, 2025

I am in favor of merging this as is. No matter, what I am saying next.

I still think it'd be better to refactor to avoid the promptly

That is something than can be done another time (after this merges) without much aditional breakage, correct?

I doubt it, and I am lacking fantasy how that API would even look like.

@Rosuavio
Copy link
Contributor Author

Rosuavio commented Sep 6, 2025

I meant additional breakage ontop of the breakage that would occure if the refactor was done now.

@Rosuavio
Copy link
Contributor Author

Rosuavio commented Oct 8, 2025

@ali-abrar no rush, but it seems everyone cleared this.

@ali-abrar ali-abrar merged commit cf0c3f3 into reflex-frp:develop Oct 19, 2025
8 checks passed
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.

scrollable: Ignores requested scroll position durring display region change event frame

4 participants