-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Only focus focusable nodes (#884)
* feat: Only focus focusable nodes * chore: Update tests * chore: Update tests * chore: Bring back a11y_focusable
- Loading branch information
Showing
13 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::{ | ||
Parse, | ||
ParseError, | ||
}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Default, Eq)] | ||
pub enum Focusable { | ||
#[default] | ||
Unknown, | ||
Disabled, | ||
Enabled, | ||
} | ||
|
||
impl Focusable { | ||
pub fn is_unknown(&self) -> bool { | ||
matches!(self, Self::Unknown) | ||
} | ||
|
||
pub fn is_enabled(&self) -> bool { | ||
matches!(self, Self::Enabled) | ||
} | ||
} | ||
|
||
impl Parse for Focusable { | ||
fn parse(value: &str) -> Result<Self, ParseError> { | ||
Ok(match value { | ||
"true" => Self::Enabled, | ||
"false" => Self::Disabled, | ||
_ => Self::Unknown, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use freya_engine::prelude::*; | ||
use freya_node_state::{ | ||
Focusable, | ||
Parse, | ||
}; | ||
|
||
#[test] | ||
fn parse_focusable_enabled() { | ||
let enabled = Focusable::parse("true"); | ||
assert_eq!(enabled, Ok(Focusable::Enabled)); | ||
} | ||
|
||
#[test] | ||
fn parse_focusable_disabled() { | ||
let disabled = Focusable::parse("false"); | ||
assert_eq!(disabled, Ok(Focusable::Disabled)); | ||
} | ||
|
||
#[test] | ||
fn parse_focusable_fallback() { | ||
let fallback = Focusable::parse("hello!!"); | ||
assert_eq!(fallback, Ok(Focusable::Unknown)); | ||
} |