Skip to content

Commit 2ac10ff

Browse files
committed
use indexmap within FocusState for tab_index and disabled state
1 parent 87816dc commit 2ac10ff

23 files changed

Lines changed: 370 additions & 343 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

preview/src/components/select/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn SelectOption<T: Clone + PartialEq + 'static>(props: SelectOptionProps<T>)
9292
text_value: props.text_value,
9393
disabled: props.disabled,
9494
id: props.id,
95-
index: props.index,
95+
tab_index: props.tab_index,
9696
aria_label: props.aria_label,
9797
aria_roledescription: props.aria_roledescription,
9898
attributes: props.attributes,

preview/src/components/select/variants/disabled/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn Demo() -> Element {
3636
let fruits = Fruit::iter().enumerate().map(|(i, f)| {
3737
rsx! {
3838
SelectOption::<Option<Fruit>> {
39-
index: i,
39+
tab_index: i,
4040
value: f,
4141
text_value: "{f}",
4242
disabled: f.disabled(),
@@ -57,7 +57,7 @@ pub fn Demo() -> Element {
5757
SelectGroup {
5858
SelectGroupLabel { "Other" }
5959
SelectOption::<Option<Fruit>> {
60-
index: Fruit::COUNT,
60+
tab_index: Fruit::COUNT,
6161
value: None,
6262
text_value: "Other",
6363
disabled: true,

preview/src/components/select/variants/main/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Fruit {
2727
pub fn Demo() -> Element {
2828
let fruits = Fruit::iter().enumerate().map(|(i, f)| {
2929
rsx! {
30-
SelectOption::<Option<Fruit>> { index: i, value: f, text_value: "{f}",
30+
SelectOption::<Option<Fruit>> { tab_index: i, value: f, text_value: "{f}",
3131
{format!("{} {f}", f.emoji())}
3232
SelectItemIndicator {}
3333
}
@@ -46,7 +46,7 @@ pub fn Demo() -> Element {
4646
SelectGroup {
4747
SelectGroupLabel { "Other" }
4848
SelectOption::<Option<Fruit>> {
49-
index: Fruit::COUNT,
49+
tab_index: Fruit::COUNT,
5050
value: None,
5151
text_value: "Other",
5252
"Other"

primitives/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dioxus-sdk-time = "0.7.0"
1717
time = { version = "0.3.41", features = ["std", "macros", "parsing"] }
1818
num-integer = "0.1.46"
1919
tracing.workspace = true
20+
indexmap = "2.12.1"
2021

2122
[build-dependencies]
2223
lazy-js-bundle = "0.6.2"

primitives/src/context_menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ pub fn ContextMenuItem(props: ContextMenuItemProps) -> Element {
463463
let focused = move || ctx.focus.is_focused(props.index.cloned());
464464

465465
// Handle settings focus
466-
let onmounted = use_focus_controlled_item(props.index);
466+
let onmounted = use_focus_controlled_item(props.index.cloned(), props.index);
467467

468468
// Determine if this item is currently focused
469469
let tab_index = use_memo(move || if focused() { "0" } else { "-1" });

primitives/src/date_picker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ fn DateSegment<T: Clone + Copy + Integer + FromStr + Display + 'static>(
550550
}
551551
};
552552

553-
let onmounted = use_focus_controlled_item(props.index);
553+
let onmounted = use_focus_controlled_item(props.index.cloned(), props.index);
554554

555555
let span_id = use_unique_id();
556556
let id = use_memo(move || format!("span-{span_id}"));

primitives/src/dropdown_menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub fn DropdownMenuItem<T: Clone + PartialEq + 'static>(
416416
let disabled = move || (ctx.disabled)() || (props.disabled)();
417417
let focused = move || ctx.focus.is_focused((props.index)());
418418

419-
let onmounted = use_focus_controlled_item(props.index);
419+
let onmounted = use_focus_controlled_item(props.index.cloned(), props.index);
420420

421421
rsx! {
422422
div {

0 commit comments

Comments
 (0)