diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 86de5f204..d668e504a 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -642,6 +642,11 @@ mod tests { let texts = frame(&mut app, vec![]); assert_eq!(stroke(&app)[which], low, "{shown}: {:?}", stroke(&app)); assert!(texts.iter().any(|(t, _)| t == after), "{shown} → {after}: {texts:?}"); + // At the bound, a step down and a step up in one frame end one step above it. + let key = |key| Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }; + frame(&mut app, vec![key(egui::Key::ArrowDown), key(egui::Key::ArrowUp)]); + let texts = frame(&mut app, vec![]); + assert!(texts.iter().any(|(t, _)| t == shown), "{after}, down and up → {shown}: {texts:?}"); } } } diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index a89a84586..00452d98d 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -390,6 +390,8 @@ fn step_value( let mut v = read(buf)?; for (mods, size, n) in steps { v = if mods == egui::Modifiers::SHIFT { v + size * n } else { step_to_multiple(v, size, n) }; + // Each step stops at the bounds, so a step back in the same frame starts from there. + v = within(v, bounds); } // Rounded as fields show it, within the field's bounds. let v = within(round_to(v, STEP_DECIMALS), bounds);