diff --git a/.github/workflows/native-playground.yml b/.github/workflows/native-playground.yml index bc3159044a..106fb26050 100644 --- a/.github/workflows/native-playground.yml +++ b/.github/workflows/native-playground.yml @@ -765,8 +765,8 @@ jobs: cmp -s "$f1" "$f2" count=$((count + 1)) done - echo "Desktop gallery verified: $count/14 PNGs byte-identical" - test "$count" -eq 14 + echo "Desktop gallery verified: $count/16 PNGs byte-identical" + test "$count" -eq 16 } if [ "${DESKTOP_LEAF_ONLY:-false}" = "true" ]; then cargo build --locked --profile test -p affine-desktop --bin desktop-harness --features affine-desktop/harness diff --git a/packages/frontend/desktop/src/bin/desktop_harness/main.rs b/packages/frontend/desktop/src/bin/desktop_harness/main.rs index 9503a04b39..97f6aa5adf 100644 --- a/packages/frontend/desktop/src/bin/desktop_harness/main.rs +++ b/packages/frontend/desktop/src/bin/desktop_harness/main.rs @@ -163,6 +163,13 @@ fn setup_states() -> Vec<(&'static str, Box)> { s.open_split_edgeless_for_active_doc(); }), ), + ( + "split-journals", + Box::new(|s| { + s.open_doc_in_split("doc-sync"); + s.navigate_active_pane(DesktopRoute::Journals); + }), + ), ( "quick-search", Box::new(|s| { diff --git a/packages/frontend/desktop/src/sidebar/controls.rs b/packages/frontend/desktop/src/sidebar/controls.rs index 738edc9dd4..caafa3b26a 100644 --- a/packages/frontend/desktop/src/sidebar/controls.rs +++ b/packages/frontend/desktop/src/sidebar/controls.rs @@ -219,7 +219,7 @@ pub(super) fn quick_actions( button( "desktop.sidebar.new_doc_options", CHEVRON_DOWN_SVG, - 18.0, + 24.0, palette, ) .when_some(trigger_bounds.clone(), |el, bounds| { diff --git a/packages/frontend/desktop/src/sidebar/mod.rs b/packages/frontend/desktop/src/sidebar/mod.rs index 3c463b042d..d8603fd30c 100644 --- a/packages/frontend/desktop/src/sidebar/mod.rs +++ b/packages/frontend/desktop/src/sidebar/mod.rs @@ -165,13 +165,11 @@ pub(crate) fn route_row( palette: DesktopPalette, cx: &Context, ) -> ui::Stateful { - nav_row(id, icon, label, selected, palette) - .snapshot(id, Some("desktop.sidebar")) - .on_click(cx.listener(move |this, _, window, cx| { - this.state.navigate_active_pane(route.clone()); - close_drawer(&mut this.state.sidebar, window); - cx.notify(); - })) + nav_row(id, icon, label, selected, palette).on_click(cx.listener(move |this, _, window, cx| { + this.state.navigate_active_pane(route.clone()); + close_drawer(&mut this.state.sidebar, window); + cx.notify(); + })) } #[allow(clippy::too_many_arguments)] @@ -217,11 +215,16 @@ pub(crate) fn render_sidebar( _ => ("desktop.sidebar.journals", "Journals"), }; route_row(id, icon, label, route, selected, palette, cx) + .snapshot(id, Some("desktop.sidebar")) })); let (scroll, max_scroll) = (sidebar.scroll_y, rows.max_scroll()); let thumb_height = (tree_height * tree_height / (tree_height + max_scroll)).max(16.0); let body = div() .id("desktop.sidebar.scroll") + .snapshot( + ui::snap_id!("desktop.sidebar.scroll"), + Some("desktop.sidebar"), + ) .relative() .flex_1() .min_h_0() diff --git a/packages/frontend/desktop/src/sidebar/tests.rs b/packages/frontend/desktop/src/sidebar/tests.rs index 484f7421e8..1dc20d35a1 100644 --- a/packages/frontend/desktop/src/sidebar/tests.rs +++ b/packages/frontend/desktop/src/sidebar/tests.rs @@ -1566,11 +1566,10 @@ mod others_and_footer { use super::*; #[test] - fn sidebar_others_places_import_below_trash_and_keeps_bottom_clearance_above_settings_divider() - { + fn sidebar_others_scrolls_import_below_trash_into_view_above_settings_divider() { use crate::SidebarSection; - for (width, height) in [(1280, 800), (390, 720)] { + for (width, height) in [(1280, 800), (1280, 720), (390, 720)] { let app = TestShell::at_size(width, height, false); if !app.shell(|view, _, _| view.state.sidebar.open) { app.click("desktop.topbar.sidebar_toggle"); @@ -1603,6 +1602,13 @@ mod others_and_footer { let import = elements["desktop.sidebar.import"].bounds; let settings = elements["desktop.sidebar.settings"].bounds; let sidebar = elements["desktop.sidebar"].bounds; + let scroll = elements["desktop.sidebar.scroll"].bounds; + for row in [trash, import] { + assert!( + row.y >= scroll.y && row.bottom() <= scroll.bottom(), + "{row:?}" + ); + } assert!(import.y > trash.y); assert_eq!(import.y, trash.y + trash.height + 2.0); assert!(import.y + import.height <= settings.y - 5.0 - 8.0 + 0.5); diff --git a/packages/frontend/desktop/src/sidebar_tree/rows.rs b/packages/frontend/desktop/src/sidebar_tree/rows.rs index f30373b551..4371478761 100644 --- a/packages/frontend/desktop/src/sidebar_tree/rows.rs +++ b/packages/frontend/desktop/src/sidebar_tree/rows.rs @@ -54,6 +54,7 @@ pub(super) fn render_row( palette, cx, ) + .snapshot("desktop.sidebar.trash", Some("desktop.sidebar.scroll")) .into_any_element(), SidebarRow::Import => nav_row( "desktop.sidebar.import", @@ -64,7 +65,7 @@ pub(super) fn render_row( ) .snapshot( ui::snap_id!("desktop.sidebar.import"), - Some("desktop.sidebar"), + Some("desktop.sidebar.scroll"), ) .when(presentation.readonly, |el| el.opacity(0.3)) .when(!presentation.readonly, |el| { @@ -352,7 +353,7 @@ impl RowPresentation<'_, '_> { .children(action.map(|(id, label)| { div() .id(id) - .snapshot(id, Some("desktop.sidebar")) + .snapshot(id, Some("desktop.sidebar.scroll")) .mt(px(8.0)) .h(px(30.0)) .px(px(8.0)) @@ -425,10 +426,10 @@ impl RowPresentation<'_, '_> { let arrow = disclosure(self.sidebar.expanded_sections.contains(§ion)); let row = div() .id(key.element_id()) - .snapshot(snap_id, Some("desktop.sidebar")) + .snapshot(snap_id, Some("desktop.sidebar.scroll")) .w_full() - .h(px(20.0)) - .mt(px(4.0)) + .h(px(24.0)) + .pt(px(4.0)) .flex_shrink(0.0) .flex() .items_center() @@ -514,7 +515,7 @@ impl RowPresentation<'_, '_> { matches!(self.active_route, DesktopRoute::Doc(id) if id == &doc_id), palette.hover_color, ) - .snapshot(snap_id, Some("desktop.sidebar")) + .snapshot(snap_id, Some("desktop.sidebar.scroll")) .pl(px(indent(depth))) .child(disclosure) .child(title_label(doc.title.clone(), palette)); @@ -553,7 +554,7 @@ impl RowPresentation<'_, '_> { self.active_route == &route, palette.hover_color, ) - .snapshot(snap_id, Some("desktop.sidebar")) + .snapshot(snap_id, Some("desktop.sidebar.scroll")) .child(disclosure) .child(title_label(label, palette)); let row = self.bind_route_open(row, route, false); @@ -636,7 +637,7 @@ impl RowPresentation<'_, '_> { ) -> ui::Stateful { let palette = self.palette; let row = row_shell(key.element_id(), active, palette.hover_color) - .snapshot(snap_id, Some("desktop.sidebar")) + .snapshot(snap_id, Some("desktop.sidebar.scroll")) .pl(px(indent(depth))) .child(self.node_icon(key, icon, expanded)) .when(!label.is_empty(), |el| { @@ -716,13 +717,13 @@ impl RowPresentation<'_, '_> { el.child( self.action_button("add", target.clone(), true) .size(px(24.0)) - .snapshot("desktop.sidebar.node.add", Some("desktop.sidebar")), + .snapshot("desktop.sidebar.node.add", Some("desktop.sidebar.scroll")), ) }) .child( self.action_button("more", target, false) .size(px(24.0)) - .snapshot("desktop.sidebar.node.more", Some("desktop.sidebar")), + .snapshot("desktop.sidebar.node.more", Some("desktop.sidebar.scroll")), ) }) } diff --git a/packages/frontend/desktop/src/views_extra/journals/mod.rs b/packages/frontend/desktop/src/views_extra/journals/mod.rs index f23869d783..146384d8c6 100644 --- a/packages/frontend/desktop/src/views_extra/journals/mod.rs +++ b/packages/frontend/desktop/src/views_extra/journals/mod.rs @@ -344,11 +344,17 @@ impl RenderOnce for CalendarView { }; let size_factor = ((width - 180.0) / 180.0).clamp(0.0, 1.0); let cell_width = (20.0 + 14.0 * size_factor).floor(); - let arrow_width = (14.0 + 10.0 * size_factor).floor(); let today_width = (46.0 + 8.0 * size_factor).floor(); let gap = 2.0; - let reserve = - 2.0 * arrow_width + gap + if show_today { today_width + gap } else { 0.0 }; + let today_reserve = if show_today { today_width + gap } else { 0.0 }; + // Web shows the arrows as 24 px icon buttons. Only a picker too narrow for them, + // Today, and one day scales them down. + let arrow_width = if width >= 48.0 + gap + today_reserve + cell_width + gap { + 24.0 + } else { + (14.0 + 10.0 * size_factor).floor() + }; + let reserve = 2.0 * arrow_width + gap + today_reserve; let count = (((width - reserve) / (cell_width + gap)) as i64).clamp(1, 7); let start = week_start(day); let first = (day - count / 2).clamp(start, start + 7 - count); diff --git a/packages/frontend/desktop/src/workbench/interaction.rs b/packages/frontend/desktop/src/workbench/interaction.rs index 8b40db8fae..debbc49f86 100644 --- a/packages/frontend/desktop/src/workbench/interaction.rs +++ b/packages/frontend/desktop/src/workbench/interaction.rs @@ -435,7 +435,10 @@ impl DesktopShellView { } let modifiers = event.keystroke.modifiers; - if key == "s" && modifiers.alt && modifiers.number_of_modifiers() == 1 { + // Like Web, let Alt+S type a non-ASCII character such as `ß` or `ś`. + let typed = event.keystroke.key_char.as_deref().unwrap_or(""); + let types_non_ascii = typed.chars().count() == 1 && typed.chars().all(|c| c > '\x7e'); + if key == "s" && modifiers.alt && modifiers.number_of_modifiers() == 1 && !types_non_ascii { let pane = self.state.split.active(); if pane .active_route() diff --git a/packages/frontend/desktop/src/workbench/interaction_tests.rs b/packages/frontend/desktop/src/workbench/interaction_tests.rs index b2c7272d01..753ee07e72 100644 --- a/packages/frontend/desktop/src/workbench/interaction_tests.rs +++ b/packages/frontend/desktop/src/workbench/interaction_tests.rs @@ -855,3 +855,76 @@ mod favorite_folder { assert_eq!(top_gap(), px(32.0)); } } + +#[cfg(test)] +mod web_parity { + use super::*; + + #[test] + fn resize_handles_and_split_indicator_leave_neighbor_controls_clickable() { + let app = Workbench::new(1440, 900); + app.shell(|view, _, cx| { + view.state.open_doc_in_split("doc-sync"); + cx.notify(); + }); + app.window.request_frame(); + for id in ["desktop.sidebar.resize", "desktop.split.resize"] { + let handle = app.bounds(id); + for x in [handle.left() - px(1.0), handle.right() + px(1.0)] { + let position = point(x, handle.center().y); + app.down(position); + app.shell(|view, _, _| assert!(view.resize.is_none(), "{id} at {x:?}")); + app.up(position); + } + } + let frame = app.shell(|_, window, _| window.frame_snapshot().clone()); + for prefix in ["desktop.topbar.", "desktop.pane.1.topbar."] { + let indicator = frame.elements[&format!("{prefix}split_indicator")].bounds; + assert_eq!(indicator.height, 24.0, "{prefix}"); + for (id, el) in frame.elements.range(prefix.to_owned()..) { + if !id.starts_with(prefix) { + break; + } + let b = el.bounds; + let (cx, cy) = (b.x + b.width / 2.0, b.y + b.height / 2.0); + assert!( + !el.interactive + || id.ends_with("split_indicator") + || cx < indicator.x + || cx >= indicator.right() + || cy < indicator.y + || cy >= indicator.bottom(), + "the split indicator {indicator:?} covers the center of {id} {b:?}" + ); + } + } + } + + #[test] + fn alt_s_switches_mode_only_when_it_types_no_non_ascii_character() { + use crate::DocViewMode; + + let app = Workbench::new(1280, 800); + let mode = || app.shell(|view, _, _| view.state.split.active().active_mode()); + for (keystroke, switches) in [ + ("alt-s", true), + ("alt-s->s", true), + ("alt-s->ß", false), + ("alt-s->ś", false), + ] { + app.shell(|view, _, cx| { + view.state.split.active_mut().set_mode(DocViewMode::Page); + cx.notify(); + }); + app.window.request_frame(); + app.focus_paragraph(false); + app.key(keystroke); + let expected = if switches { + DocViewMode::Edgeless + } else { + DocViewMode::Page + }; + assert_eq!(mode(), expected, "{keystroke}"); + } + } +} diff --git a/packages/frontend/desktop/src/workbench/topbar/mod.rs b/packages/frontend/desktop/src/workbench/topbar/mod.rs index a8ced36935..7e027bdece 100644 --- a/packages/frontend/desktop/src/workbench/topbar/mod.rs +++ b/packages/frontend/desktop/src/workbench/topbar/mod.rs @@ -317,37 +317,65 @@ pub(super) fn render_detail_header( let pane_id = pane.id; let split_indicator = split_visible.then(|| { let active = shell.state.split.active_pane == index; - let indicator = button( - id("split_indicator"), - false, - palette, - cx.listener(move |this, _, _, cx| { - if let Some(index) = this - .state - .split - .panes - .iter() - .position(|pane| pane.id == pane_id) - { - this.state.split.focus_pane(index); - cx.notify(); - } - }), - ) - .w(px(36.0)) - .h(px(if journal || route == &DesktopRoute::Journals { - 6.0 + let compact = journal || route == &DesktopRoute::Journals; + let group = SharedString::from(format!("split-indicator-{index}")); + // The journal week picker leaves only a 6 px strip, so there the dots take no + // pointer input: a press on them reaches the pane, which focuses on any press. + // Elsewhere the target takes the Web minimum width of 120 px, so it stays clear of + // the header buttons. It keeps the dots where the 12 px strip centered them and + // colors them on hover. + let indicator = if compact { + let ControlId { element, snapshot } = id("split_indicator"); + div() + .id(element) + .snapshot(snapshot, Some("desktop.workbench.topbar")) + .w(px(36.0)) + .h(px(6.0)) + .rounded(px(6.0)) + .flex() + .items_center() + .justify_center() + .hover(move |s| s.bg(palette.bg_hover)) } else { - 12.0 - })) - .occlude() + button_with_hover( + id("split_indicator"), + false, + ui::transparent_black(), + palette, + cx.listener(move |this, _, _, cx| { + if let Some(index) = this + .state + .split + .panes + .iter() + .position(|pane| pane.id == pane_id) + { + this.state.split.focus_pane(index); + cx.notify(); + } + }), + ) + .group(group.clone()) + .w(px(120.0)) + .h(px(24.0)) + .items_start() + .pt(px(4.5)) + .occlude() + } .gap(px(3.0)) .children((0..3).map(|_| { - div().w(px(3.0)).h(px(3.0)).rounded(px(1.5)).bg(if active { - palette.accent - } else { - palette.border_strong - }) + div() + .w(px(3.0)) + .h(px(3.0)) + .rounded(px(1.5)) + .bg(if active { + palette.accent + } else { + palette.border_strong + }) + .when(!compact, |dot| { + dot.group_hover(group.clone(), move |s| s.bg(palette.accent)) + }) })); div() .absolute() diff --git a/packages/frontend/scripts/check-snapshot-prefixes.mjs b/packages/frontend/scripts/check-snapshot-prefixes.mjs index aad065516d..2352ee1dfd 100644 --- a/packages/frontend/scripts/check-snapshot-prefixes.mjs +++ b/packages/frontend/scripts/check-snapshot-prefixes.mjs @@ -277,6 +277,9 @@ export const ZERO_IN_PRODUCTION = Object.freeze([ 'desktop.settings.delete_workspace_confirm.title', 'desktop.settings.storage.export', 'desktop.trash.select.', + 'desktop.sidebar.fav_doc.', + 'desktop.sidebar.fav_folder.', + 'desktop.sidebar.fav_group.', ]); const WASM_MAGIC = new Uint8Array([0x00, 0x61, 0x73, 0x6d]); diff --git a/packages/frontend/scripts/check-snapshot-prefixes.test.mjs b/packages/frontend/scripts/check-snapshot-prefixes.test.mjs index 8c38fd33f5..1f2e621a07 100644 --- a/packages/frontend/scripts/check-snapshot-prefixes.test.mjs +++ b/packages/frontend/scripts/check-snapshot-prefixes.test.mjs @@ -255,6 +255,12 @@ const SETTINGS_AND_TRASH_SELECT_PREFIXES = [ 'desktop.trash.select.', ]; +const FAVORITE_ROW_PREFIXES = [ + 'desktop.sidebar.fav_doc.', + 'desktop.sidebar.fav_folder.', + 'desktop.sidebar.fav_group.', +]; + const NON_OVERLAPPING_PREFIXES = new Set([ 'desktop.explorer.display.body', 'desktop.explorer.display.icon', @@ -264,6 +270,7 @@ const NON_OVERLAPPING_PREFIXES = new Set([ 'desktop.trash_prompt.title', ...DISPLAY_AND_LINK_PICKER_PREFIXES, ...SETTINGS_AND_TRASH_SELECT_PREFIXES, + ...FAVORITE_ROW_PREFIXES, ]); /** @@ -363,8 +370,8 @@ test('rejects bare snapshot container IDs in Wasm Data segments', () => { } }); -test('verifies all 257 live prefixes including desktop production sources', () => { - assert.equal(ZERO_IN_PRODUCTION.length, 257); +test('verifies all 260 live prefixes including desktop production sources', () => { + assert.equal(ZERO_IN_PRODUCTION.length, 260); const firstBatchAdditions = ZERO_IN_PRODUCTION.slice(81, 175); assert.deepEqual( firstBatchAdditions, @@ -407,7 +414,7 @@ test('verifies all 257 live prefixes including desktop production sources', () = ZERO_IN_PRODUCTION.slice(246, 250), DISPLAY_AND_LINK_PICKER_PREFIXES ); - const settingsAndTrashAdditions = ZERO_IN_PRODUCTION.slice(250); + const settingsAndTrashAdditions = ZERO_IN_PRODUCTION.slice(250, 257); assert.deepEqual( settingsAndTrashAdditions, SETTINGS_AND_TRASH_SELECT_PREFIXES, @@ -418,6 +425,17 @@ test('verifies all 257 live prefixes including desktop production sources', () = [...settingsAndTrashAdditions].sort(), 'Settings and trash select prefixes must stay sorted lexicographically' ); + const favoriteRowAdditions = ZERO_IN_PRODUCTION.slice(257); + assert.deepEqual( + favoriteRowAdditions, + FAVORITE_ROW_PREFIXES, + 'Favorite row prefixes must match appended order' + ); + assert.deepEqual( + favoriteRowAdditions, + [...favoriteRowAdditions].sort(), + 'Favorite row prefixes must stay sorted lexicographically' + ); assert.equal( new Set(ZERO_IN_PRODUCTION).size, ZERO_IN_PRODUCTION.length, @@ -473,6 +491,7 @@ test('verifies all 257 live prefixes including desktop production sources', () = ...SHELL_CONTAINER_AND_DIALOG_PREFIXES, ...DISPLAY_AND_LINK_PICKER_PREFIXES, ...SETTINGS_AND_TRASH_SELECT_PREFIXES, + ...FAVORITE_ROW_PREFIXES, ]) { for (const existing of ZERO_IN_PRODUCTION) { if (existing === prefix) continue; @@ -496,7 +515,7 @@ test('verifies all 257 live prefixes including desktop production sources', () = true, `Missing prefixes in repo: ${result.missing.join(', ')}` ); - assert.equal(Object.keys(result.counts).length, 257); + assert.equal(Object.keys(result.counts).length, 260); for (const prefix of [ ...DESKTOP_PREFIXES, ...NEW_DESKTOP_PREFIXES, @@ -507,6 +526,7 @@ test('verifies all 257 live prefixes including desktop production sources', () = ...SHELL_CONTAINER_AND_DIALOG_PREFIXES, ...DISPLAY_AND_LINK_PICKER_PREFIXES, ...SETTINGS_AND_TRASH_SELECT_PREFIXES, + ...FAVORITE_ROW_PREFIXES, ]) { assert.ok( result.counts[prefix] >= 1, @@ -713,7 +733,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s encoding: 'utf8', }); assert.equal(passRun.status, 0, passRun.stderr); - assert.match(passRun.stdout, /257\/257 prefixes at 0/); + assert.match(passRun.stdout, /260\/260 prefixes at 0/); const desktopOnlyOptWasm = join(dir, 'affine_desktop_bg.opt.wasm'); writeFileSync( @@ -726,7 +746,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s { encoding: 'utf8' } ); assert.equal(singleRun.status, 0, singleRun.stderr); - assert.match(singleRun.stdout, /257\/257 prefixes at 0/); + assert.match(singleRun.stdout, /260\/260 prefixes at 0/); assert.match(singleRun.stdout, /affine_desktop_bg\.opt\.wasm/); } finally { rmSync(dir, { recursive: true, force: true }); diff --git a/packages/ui/ui/src/harness.rs b/packages/ui/ui/src/harness.rs index d3ecf0e72b..62cac81f35 100644 --- a/packages/ui/ui/src/harness.rs +++ b/packages/ui/ui/src/harness.rs @@ -127,12 +127,12 @@ mod active { /// Zero-cost no-op frame snapshot collector used when the `harness` feature is disabled. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] - pub struct FrameSnapshot; + pub struct FrameSnapshot(()); impl FrameSnapshot { #[inline] pub fn new(_width: f32, _height: f32, _scale_factor: f32) -> Self { - Self + Self(()) } #[inline] diff --git a/tools/frame-audit/src/audit.rs b/tools/frame-audit/src/audit.rs index 2a266252b1..2ae28539e1 100644 --- a/tools/frame-audit/src/audit.rs +++ b/tools/frame-audit/src/audit.rs @@ -11,6 +11,10 @@ const ALIGN_TOLERANCE: f32 = 0.5; const MIN_RADIUS_STEP: f32 = 4.0; /// Smallest interactive target, in logical pixels. const MIN_HIT_TARGET: f32 = 24.0; +/// Smallest thickness and length of a resize handle that is dragged along +/// one axis only, in logical pixels. +const MIN_RESIZE_THICKNESS: f32 = 6.0; +const MIN_RESIZE_LENGTH: f32 = 48.0; /// Rule identifiers reported in [`AuditViolation::rule`]. pub mod rules { @@ -19,7 +23,8 @@ pub mod rules { /// An invisible element is interactive, or the renderer's hit test /// delivered a point to it. pub const ZERO_OPACITY_HIT_THROUGH: &str = "zero-opacity-hit-through"; - /// Interactive element smaller than 24 x 24. + /// Interactive element smaller than 24 x 24, unless it is a resize handle + /// at least 6 thick and 48 long. pub const MIN_HIT_TARGET: &str = "min-hit-target"; /// Negative radius, or an inner radius above `max(R_outer - padding, 4)`. pub const CONCENTRIC_CORNER_RADIUS: &str = "concentric-corner-radius"; @@ -129,7 +134,13 @@ fn element_rules(snapshot: &FrameSnapshot, el: &DebugElementSnapshot, out: &mut } let min_hit_target = minimum_hit_target(snapshot, el); - if el.interactive && (b.width < min_hit_target || b.height < min_hit_target) { + let (thickness, length) = match el.cursor { + Some(CursorStyle::ResizeColumn) => (b.width, b.height), + Some(CursorStyle::ResizeRow) => (b.height, b.width), + _ => (0.0, 0.0), + }; + let resize_handle = thickness >= MIN_RESIZE_THICKNESS && length >= MIN_RESIZE_LENGTH; + if el.interactive && !resize_handle && (b.width < min_hit_target || b.height < min_hit_target) { push( out, rules::MIN_HIT_TARGET, diff --git a/tools/frame-audit/src/lib.rs b/tools/frame-audit/src/lib.rs index 21aca9c38f..9c328572e7 100644 --- a/tools/frame-audit/src/lib.rs +++ b/tools/frame-audit/src/lib.rs @@ -93,6 +93,10 @@ pub enum CursorStyle { Text, Grab, NotAllowed, + /// Drags a vertical edge sideways (a column or pane resize handle). + ResizeColumn, + /// Drags a horizontal edge up or down (a row resize handle). + ResizeRow, } /// Laid-out text evidence in absolute logical pixels. diff --git a/tools/frame-audit/src/tests.rs b/tools/frame-audit/src/tests.rs index 1ee3433eaf..c4cd7f309d 100644 --- a/tools/frame-audit/src/tests.rs +++ b/tools/frame-audit/src/tests.rs @@ -314,6 +314,40 @@ fn cases() -> Vec { ), vec![(rules::TEXT_TRUNCATION, "body")], ), + ( + "resize handles are one-axis targets and narrow buttons still fail", + frame( + vec![ + el("sash.column", 100.0, 0.0, 8.0, 700.0) + .with_interactive(true) + .with_cursor(CursorStyle::ResizeColumn), + el("sash.row", 0.0, 720.0, 390.0, 6.0) + .with_interactive(true) + .with_cursor(CursorStyle::ResizeRow), + el("sash.short", 120.0, 0.0, 8.0, 40.0) + .with_interactive(true) + .with_cursor(CursorStyle::ResizeColumn), + el("sash.thin", 140.0, 0.0, 4.0, 700.0) + .with_interactive(true) + .with_cursor(CursorStyle::ResizeColumn), + el("sash.crossways", 160.0, 0.0, 8.0, 700.0) + .with_interactive(true) + .with_cursor(CursorStyle::ResizeRow), + el("bar.no_cursor", 180.0, 0.0, 8.0, 700.0).with_interactive(true), + el("button.small", 200.0, 0.0, 18.0, 28.0) + .with_interactive(true) + .with_cursor(CursorStyle::Pointer), + ], + &[], + ), + vec![ + (rules::MIN_HIT_TARGET, "sash.short"), + (rules::MIN_HIT_TARGET, "sash.thin"), + (rules::MIN_HIT_TARGET, "sash.crossways"), + (rules::MIN_HIT_TARGET, "bar.no_cursor"), + (rules::MIN_HIT_TARGET, "button.small"), + ], + ), ] }