diff --git a/crates/story/src/input_story.rs b/crates/story/src/input_story.rs index e7965520..d7ac9734 100644 --- a/crates/story/src/input_story.rs +++ b/crates/story/src/input_story.rs @@ -1,6 +1,6 @@ use gpui::{ - div, App, AppContext as _, Context, Entity, InteractiveElement, IntoElement, - ParentElement as _, Render, Styled, Subscription, Window, + App, AppContext as _, Context, Entity, InteractiveElement, IntoElement, ParentElement as _, + Render, Styled, Subscription, Window, div, }; use crate::section; @@ -121,13 +121,20 @@ impl InputStory { &mut self, state: &Entity, event: &InputEvent, - _window: &mut Window, - _cx: &mut Context, + window: &mut Window, + cx: &mut Context, ) { match event { InputEvent::Change => { - let text = state.read(_cx).value(); - println!("Change: {}", text) + let text = state.read(cx).value(); + if state == &self.input2 { + println!("Set disabled value: {}", text); + self.disabled_input.update(cx, |this, cx| { + this.set_value(text, window, cx); + }) + } else { + println!("Change: {}", text) + } } InputEvent::PressEnter { secondary } => println!("PressEnter secondary: {}", secondary), InputEvent::Focus => println!("Focus"), diff --git a/crates/ui/src/input/state.rs b/crates/ui/src/input/state.rs index 5bb1d2b7..11d10405 100644 --- a/crates/ui/src/input/state.rs +++ b/crates/ui/src/input/state.rs @@ -637,6 +637,7 @@ impl InputState { ) { self.history.ignore = true; let was_disabled = self.disabled; + self.disabled = false; self.replace_text(value, window, cx); self.disabled = was_disabled; self.history.ignore = false;