From 633988768c7cf5dd761da51d85cdb102c688c05d Mon Sep 17 00:00:00 2001 From: adammharris Date: Thu, 26 Nov 2026 14:49:31 -0700 Subject: [PATCH 1/2] fix: a tick, an arrow and a toast's close are icons, not characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A checkbox's ✓, a menu's tick and its submenu's ▸, a select's ▾, a disclosure's ▸ and ▾ and a toast's ✕ were text, drawn only where the system's font has those characters. Redox's (Fira) has none of them: each drew as a missing glyph's box. They are unit's own icons now (`paths::CHECK`, `CHEVRON_RIGHT`, `CHEVRON_DOWN`, `CLOSE`), stroked in the colour the text there had, so they look the same with every font. A tick and a submenu's arrow keep no gap after them in a menu row. Behavioural-change: those marks are SVG icons; a test that found a submenu's row by its text with the arrow ("Heading▸") finds it by its label alone. --- gallery/tests/blitz.rs | 2 +- src/components/choice.rs | 3 ++- src/components/menus.rs | 6 ++++-- src/components/navigation.rs | 2 +- src/layer.rs | 13 ++++++++----- src/style.rs | 2 ++ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gallery/tests/blitz.rs b/gallery/tests/blitz.rs index 14b4bce..870f131 100644 --- a/gallery/tests/blitz.rs +++ b/gallery/tests/blitz.rs @@ -261,7 +261,7 @@ fn a_submenu_opens_beside_its_item() { let mut doc = page(1200, 800); let edit = find(&doc, "button", "Edit ▾"); click(&mut doc, edit); - let heading = find(&doc, ".unit-item", "Heading▸"); + let heading = find(&doc, ".unit-item", "Heading"); let (hx, hy, hw, hh) = rect(&doc, heading); doc.handle_ui_event(UiEvent::PointerMove(pointer( BlitzPointerId::Mouse, diff --git a/src/components/choice.rs b/src/components/choice.rs index f82b3d7..4bcee5b 100644 --- a/src/components/choice.rs +++ b/src/components/choice.rs @@ -9,6 +9,7 @@ use dioxus::html::{Key, Modifiers, NamedKey}; use dioxus::prelude::*; +use crate::icon::{Icon, paths}; use crate::unit::{Kind, next_id, use_focus}; fn is_space(key: &Key) -> bool { @@ -49,7 +50,7 @@ pub fn Checkbox( } }, span { class: "unit-check-box", "aria-hidden": "true", - if checked { "✓" } + if checked { Icon { d: paths::CHECK, size: 12.0 } } } span { class: "unit-check-label", {children} } } diff --git a/src/components/menus.rs b/src/components/menus.rs index 8961607..b922ba4 100644 --- a/src/components/menus.rs +++ b/src/components/menus.rs @@ -14,7 +14,7 @@ use dioxus::prelude::*; use crate::components::button::{Variant, is_press}; use crate::components::choice::{Orientation, arrow_step}; use crate::components::hold::use_hold; -use crate::icon::Icon; +use crate::icon::{Icon, paths}; use crate::menu::{Entry, Item}; use crate::unit::{Kind, Unit, use_focus, use_unit}; @@ -262,7 +262,9 @@ pub fn Select( rsx! { MenuButton { class: "unit-select", entries, onpick, height, label: name, disabled, span { class: "unit-select-label", "{shown}" } - span { class: "unit-select-arrows", "aria-hidden": "true", "▾" } + span { class: "unit-select-arrows", "aria-hidden": "true", + Icon { d: paths::CHEVRON_DOWN, size: 14.0 } + } } } } diff --git a/src/components/navigation.rs b/src/components/navigation.rs index 6ba3872..b03fddf 100644 --- a/src/components/navigation.rs +++ b/src/components/navigation.rs @@ -183,7 +183,7 @@ pub fn Disclosure(title: String, #[props(default)] open: bool, children: Element shown.toggle(); }, span { class: "unit-disclosure-arrow", "aria-hidden": "true", - if is_open { "▾" } else { "▸" } + Icon { d: if is_open { paths::CHEVRON_DOWN } else { paths::CHEVRON_RIGHT }, size: 14.0 } } "{title}" } diff --git a/src/layer.rs b/src/layer.rs index eb51d89..eed1963 100644 --- a/src/layer.rs +++ b/src/layer.rs @@ -27,7 +27,7 @@ use dioxus::prelude::*; use crate::actions::{ActionSheet, SheetAction}; use crate::dialog::{Answer, Dialog, Field, FieldKey}; -use crate::icon::{Icon, Ink}; +use crate::icon::{Icon, Ink, paths}; use crate::menu::{Entry, Level, Menu, Outcome, Sizes}; use crate::unit::{Keys, Unit, next_id}; @@ -662,7 +662,6 @@ fn entry_view(unit: Unit, depth: usize, i: usize, entry: &Entry, lit: Option { - let tick = if item.checked { "✓" } else { "" }; let shortcut = item.shortcut.clone().unwrap_or_default(); let role = if item.checkable { "menuitemcheckbox" @@ -681,7 +680,9 @@ fn entry_view(unit: Unit, depth: usize, i: usize, entry: &Entry, lit: Option unreachable!("drawn by palette_view"), @@ -992,7 +995,7 @@ fn ToastView(unit: Unit, id: u64, toast: Toast, #[props(default)] leaving: bool) e.stop_propagation(); unit.dismiss(id); }, - "✕" + Icon { d: paths::CLOSE, size: 16.0 } } } } diff --git a/src/style.rs b/src/style.rs index ce4a2d3..3682499 100644 --- a/src/style.rs +++ b/src/style.rs @@ -44,6 +44,8 @@ pub const CSS: &str = r#" .unit-label { flex: 1; } .unit-key { flex: none; padding-left: 18px; color: var(--unit-dim); } .unit-item.hot .unit-key { color: var(--unit-accent-text); } +/* A tick and a submenu's arrow are icons in a column of their own: no gap after them. */ +.unit-tick .unit-svg, .unit-key .unit-svg { margin-right: 0; } .unit-sep { height: 9px; padding: 4px 10px; } .unit-item.unit-header { color: var(--unit-dim); font-size: 0.85em; font-weight: 600; } .unit-rule { height: 1px; background: var(--unit-separator); } From 02505dc7d1e3b9fb184e544e6bf499489336e03c Mon Sep 17 00:00:00 2001 From: adammharris Date: Thu, 26 Nov 2026 14:49:31 -0700 Subject: [PATCH 2/2] feat(textfield): a search or text field can have the keys when the page opens `autofocus` on SearchField and TextField, written as the element's `autofocus` attribute, which Blitz (with its `autofocus` feature) and a browser honour: a launcher's search takes what is typed as soon as its window opens. --- src/components/text_field.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/text_field.rs b/src/components/text_field.rs index b251536..f885053 100644 --- a/src/components/text_field.rs +++ b/src/components/text_field.rs @@ -84,6 +84,10 @@ pub fn TextField( #[props(default)] required: bool, minlength: Option, maxlength: Option, + /// Whether the field has the keys when the page opens, as a browser's + /// `autofocus`: a dialog's one field. + #[props(default)] + autofocus: bool, ) -> Element { let focus = use_focus(Kind::Text, |_, _| false); let id = use_hook(next_id); @@ -113,6 +117,7 @@ pub fn TextField( "aria-required": required.then_some("true"), minlength: minlength.map(|n| n.to_string()), maxlength: maxlength.map(|n| n.to_string()), + autofocus: autofocus.then_some("true"), "aria-label": label.clone(), onpointerdown: move |_| focus.press(), onfocus: move |_| focus.dom_focus(), @@ -219,6 +224,10 @@ pub fn SearchField( label: String, #[props(default = "Search".to_string())] placeholder: String, onsubmit: Option>, + /// Whether the field has the keys when the page opens, as a browser's + /// `autofocus`: a launcher's search. + #[props(default)] + autofocus: bool, #[props(default)] class: String, ) -> Element { let focus = use_focus(Kind::Text, |_, _| false); @@ -233,6 +242,7 @@ pub fn SearchField( r#type: "search", value: "{value}", placeholder: "{placeholder}", + autofocus: autofocus.then_some("true"), "aria-label": "{label}", onpointerdown: move |_| focus.press(), onfocus: move |_| focus.dom_focus(),