input: Clean to reset selection and scroll offset. (#1326)
- Focus back to input when click `clean` button.
This commit is contained in:
parent
9754cab4d7
commit
a48232cefd
2 changed files with 3 additions and 0 deletions
|
|
@ -1512,6 +1512,8 @@ impl InputState {
|
||||||
|
|
||||||
pub(super) fn clean(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
pub(super) fn clean(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
self.replace_text("", window, cx);
|
self.replace_text("", window, cx);
|
||||||
|
self.selected_range = (0..0).into();
|
||||||
|
self.scroll_to(0, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn escape(&mut self, action: &Escape, window: &mut Window, cx: &mut Context<Self>) {
|
pub(super) fn escape(&mut self, action: &Escape, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
|
|
||||||
|
|
@ -406,6 +406,7 @@ impl RenderOnce for TextInput {
|
||||||
move |_, window, cx| {
|
move |_, window, cx| {
|
||||||
state.update(cx, |state, cx| {
|
state.update(cx, |state, cx| {
|
||||||
state.clean(window, cx);
|
state.clean(window, cx);
|
||||||
|
state.focus(window, cx);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue