Skip to content

Commit ffc1c69

Browse files
committed
feat: Support dialogs in the consumer crate
1 parent a47bca1 commit ffc1c69

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

consumer/src/node.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ impl<'a> Node<'a> {
413413
})
414414
}
415415

416+
pub fn is_dialog(&self) -> bool {
417+
matches!(self.role(), Role::AlertDialog | Role::Dialog)
418+
}
419+
420+
pub fn is_modal(&self) -> bool {
421+
self.data().is_modal()
422+
}
423+
416424
// When probing for supported actions as the next several functions do,
417425
// it's tempting to check the role. But it's better to not assume anything
418426
// beyond what the provider has explicitly told us. Rationale:

consumer/src/tree.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ impl State {
221221
self.focus_id().map(|id| self.node_by_id(id).unwrap())
222222
}
223223

224+
pub fn active_dialog(&self) -> Option<Node<'_>> {
225+
let mut node = self.focus();
226+
while let Some(candidate) = node {
227+
if candidate.is_dialog() {
228+
return Some(candidate);
229+
}
230+
node = candidate.parent();
231+
}
232+
None
233+
}
234+
224235
pub fn toolkit_name(&self) -> Option<&str> {
225236
self.data.toolkit_name.as_deref()
226237
}

0 commit comments

Comments
 (0)