Skip to content

Commit 7a444c8

Browse files
committed
feat: Support dialogs in the consumer crate
1 parent daf5faf commit 7a444c8

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
@@ -415,6 +415,14 @@ impl<'a> Node<'a> {
415415
})
416416
}
417417

418+
pub fn is_dialog(&self) -> bool {
419+
matches!(self.role(), Role::AlertDialog | Role::Dialog)
420+
}
421+
422+
pub fn is_modal(&self) -> bool {
423+
self.data().is_modal()
424+
}
425+
418426
// When probing for supported actions as the next several functions do,
419427
// it's tempting to check the role. But it's better to not assume anything
420428
// 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)