mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 00:34:25 +00:00
A dialog opens on its first text or number field, else its default button, else nothing (Initial::FirstField, the DIALOG policy's default). The per-dialog first-pass focus requests in Markers, Slice options and Page Setup go: the rule gives the same field. focus::request reports whether it took effect, so a pending request outlives a measuring run.
23 lines
996 B
Rust
23 lines
996 B
Rust
//! The password dialog keeps the keyboard in its field.
|
|
|
|
use craft_ui::patterns::form_dialogs::{PasswordDialog, PasswordPurpose};
|
|
use craft_ui::testing::{Fixture, trial};
|
|
|
|
fn focused_on(fixture: &Fixture, label: &str) -> bool {
|
|
let focused = craft_ui::testing::access::focused_key(fixture.tree());
|
|
fixture.by_label(label).is_some_and(|target| target.node == focused)
|
|
}
|
|
|
|
#[trial]
|
|
fn the_reveal_button_hands_the_focus_back_to_the_field() {
|
|
let mut fixture = Fixture::new(|ui| {
|
|
let _ = PasswordDialog::new(PasswordPurpose::open("poster.pdf")).show(ui);
|
|
});
|
|
fixture.idle(30);
|
|
assert!(focused_on(&fixture, "Password"), "the dialog opens on the field");
|
|
let reveal = fixture.by_label("Show password").expect("the reveal button is shown");
|
|
fixture.click(&reveal).idle(4);
|
|
assert!(fixture.by_label("Hide password").is_some(), "the press revealed the text");
|
|
assert!(focused_on(&fixture, "Password"), "the field has the focus back, so typing goes on");
|
|
}
|