input: Fix set_value when Input is disabled. (#1362)

Close #1350
This commit is contained in:
Jason Lee 2025-10-13 11:15:32 +08:00 committed by GitHub
parent 08cf199b39
commit 97df4efd46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View file

@ -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<InputState>,
event: &InputEvent,
_window: &mut Window,
_cx: &mut Context<Self>,
window: &mut Window,
cx: &mut Context<Self>,
) {
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"),

View file

@ -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;