From cfc9f6fab1cfc61650ababf8dd3402a6304e1a12 Mon Sep 17 00:00:00 2001 From: temportalflux Date: Fri, 3 Jul 2026 13:41:24 -0400 Subject: [PATCH] update documentation of 'use_keyed_transition', 'use_keyed_state', & 'with_element_state' to make it clear that the functions can be called during 'render' implementations, as 'examples/learn/transition.rs' illustrates --- crates/gpui/src/window.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index b5a2faab92..5276fb15dc 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -3357,6 +3357,8 @@ impl Window { } /// Use a piece of state that exists as long this element is being rendered in consecutive frames. + /// + /// This method should only be called during `Render::render`, `RenderOnce::render`, or the drawing functions of `Element`. pub fn use_keyed_state( &mut self, key: impl Into, @@ -3401,7 +3403,9 @@ impl Window { /// Updates or initializes state for an element with the given id that lives across multiple /// frames. If an element with this ID existed in the rendered frame, its state will be passed /// to the given closure. The state returned by the closure will be stored so it can be referenced - /// when drawing the next frame. This method should only be called as part of element drawing. + /// when drawing the next frame. + /// + /// This method should only be called during `Render::render`, `RenderOnce::render`, or the drawing functions of `Element`. pub fn with_element_state( &mut self, global_id: &GlobalElementId, @@ -3531,6 +3535,8 @@ impl Window { /// persist across renders as long as the key remains the same. This is the /// recommended method for most use cases where you want smooth, continuous /// animations. + /// + /// This method should only be called during `Render::render`, `RenderOnce::render`, or the drawing functions of `Element`. pub fn use_keyed_transition( &mut self, key: impl Into,