Making an AnyElement
scrollable
#6886
Replies: 2 comments 3 replies
-
In GPUI, the element tree you construct in ‘render’ is only used for a single frame. But some elements need some minor state tracking in order to provide the services they do, such as the current scroll offset. In order to carry this state across frames, we use the element id to lookup the element’s state. The ID is optional because you only really need to do this for certain kinds of interactivity, for common cases, this is useless clutter. As for the scroll issue, you might need to add a ‘size_full()’ to your div so it knows what bounds it’s in. if that doesn’t fix it, let me know and I’ll be at my desk to take a closer look later :) |
Beta Was this translation helpful? Give feedback.
-
To add to the last part of the previous answer (sorry, was typing that but too long): there has to be be a Albeit your PR is on early stages, a few notes I'd love to add there:
|
Beta Was this translation helpful? Give feedback.
-
I'm working on a markdown preview action.
Preview:
zed.-.markdown.preview.mov
I'm reusing the workspace's
rich_text
crate:I'm unable to make the markdown preview scrollable.
A) I noticed that I'm only able to apply
.overflow_y_scroll()
if I assign adiv
an id. I'm struggling to understand why this is. I understandid
returns aStateful
instance of thediv
which implementsInteractiveElement
, but I don't understand why that's not the default.B) Applying overflow on the parent
div
does not make.child(text.element("body".into(), cx));
scrollable as expected. What's the correct path forward? To casttext.element("body".into(), cx)
back into anInteractiveText
and then to implementInteractiveElement
forInteractiveText
?Beta Was this translation helpful? Give feedback.
All reactions