Accessibility: Tab no longer stops on the Simplify and Smooth sliders' backdrop

The backdrop that takes a click outside the slider strip sensed clicks
with Sense::click(), which egui makes focusable, so Tab stopped on an
invisible full-screen widget. It now uses Sense::CLICK, as the modal
dialog backdrop does; a click outside the strip still keeps the result.
This commit is contained in:
dotCooCoo
2026-11-02 12:04:09 +07:00
committed by bflatastic
parent 53e24b5fdc
commit 8bccbf2f35
2 changed files with 24 additions and 1 deletions
@@ -103,9 +103,10 @@ impl Strip {
let b = bounds(app, &mut d);
let pos = place(app, ctx, id, b);
// A click anywhere else keeps the result, and the rest of the app doesn't take it.
// Not focusable (`Sense::click()` is): Tab goes through the strip's controls, not the backdrop.
let dim = modal::backdrop();
let outside =
egui::Area::new(dim.id).order(dim.order).fixed_pos(Pos2::ZERO).show(ctx, |ui| ui.allocate_rect(ctx.content_rect(), Sense::click())).inner;
egui::Area::new(dim.id).order(dim.order).fixed_pos(Pos2::ZERO).show(ctx, |ui| ui.allocate_rect(ctx.content_rect(), Sense::CLICK)).inner;
let mut action: Option<Button> = None;
egui::Area::new(id).order(Order::Foreground).fixed_pos(pos).show(ctx, |ui| {
egui::Frame::NONE
+22
View File
@@ -575,6 +575,28 @@ fn smooth_slider_previews_auto_smooth_and_keeps_the_result() {
assert_ne!(app.session.doc().unwrap().doc, before);
}
/// Tab goes through the controls of the Simplify and Smooth sliders' strip and does not stop on the
/// backdrop that takes a click outside it.
#[test]
fn tab_skips_the_backdrop_of_the_simplify_and_smooth_sliders() {
for (menu, kind) in [("object.path.simplify", simplify_slider::KIND), ("object.path.smooth", smooth_slider::KIND)] {
let (ctx, mut app) = (ctx(), app_with_dense_path());
crate::menus::invoke(&mut app, menu, json!({}));
settle(&ctx, &mut app);
let strip = rect_of(&ctx, egui::Id::unique(("dialog", kind)));
let stops = crate::widgets::accessibility_tests::tab_stops(&ctx, 30, |events| {
frame(&ctx, &mut app, events);
});
let inside = |s: &egui::Id| ctx.read_response(*s).is_some_and(|r| r.rect.is_positive() && strip.contains_rect(r.rect));
assert!(stops.iter().any(inside), "{kind}: Tab reaches a control in the strip: {stops:?}");
let backdrop: Vec<egui::Id> = ctx.viewport(|vp| {
vp.prev_pass.widgets.layers().filter(|(l, _)| **l == modal::backdrop()).flat_map(|(_, w)| w.iter()).map(|w| w.id).collect()
});
assert!(!backdrop.is_empty(), "{kind}: the backdrop is drawn");
assert!(!stops.iter().any(|id| backdrop.contains(id)), "{kind}: Tab stops on the backdrop: {stops:?}");
}
}
/// More Options opens the Simplify dialog at the slider's tolerance. With "Open this dialog with
/// these settings next time" ticked, OK makes the menu item open the dialog on its settings; with
/// it unticked, the slider again.