Skip to content

Commit 687ff73

Browse files
committed
fix jitters when editing JSON property in editor
1 parent 4215043 commit 687ff73

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/demo/src/apps/editor.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,18 @@ impl Editor {
290290
}
291291

292292
fn show_text_edit_with_focus(ui: &mut Ui, input: &mut String, request_focus: &mut bool) {
293-
let text_edit_output = TextEdit::singleline(input)
294-
.code_editor()
295-
.margin(Margin::symmetric(2, 0))
296-
.clip_text(false)
297-
.desired_width(0.0)
298-
.min_size(vec2(10.0, 2.0))
299-
.show(ui);
293+
// Wrap in horizontal to prevent jitters when typing when children are expanded (due to use of horizontal_wrapped when rendering properties).
294+
let text_edit_output = ui
295+
.horizontal(|ui| {
296+
TextEdit::singleline(input)
297+
.code_editor()
298+
.margin(Margin::symmetric(2, 0))
299+
.clip_text(false)
300+
.desired_width(0.0)
301+
.min_size(vec2(10.0, 2.0))
302+
.show(ui)
303+
})
304+
.inner;
300305

301306
if *request_focus {
302307
*request_focus = false;

0 commit comments

Comments
 (0)