Skip to content

Commit 5e504d1

Browse files
authored
chore: Refactor tab key to switch focus. (#991)
Wait zed-industries/zed#33008, zed-industries/zed#34804 to merge. https://github.com/user-attachments/assets/3c21ebc9-44a0-4311-bb0f-5f63fe8d4bb3 - Improved `focus_ring` to render like an outline. - Added to support press `Enter`, `Space` key to trigger Checkbox, Button, Radio. ## Break Changes - The `FocusableExt` has been changed to only for crate internal. - The `FocusableCycle` has been removed, now GPUI has it own tab stop implementation.
1 parent ed05c3e commit 5e504d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+719
-611
lines changed

Cargo.lock

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

crates/story/src/accordion_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl super::Story for AccordionStory {
3232
"The accordion uses collapse internally to make it collapsible."
3333
}
3434

35-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
35+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
3636
Self::view(window, cx)
3737
}
3838
}

crates/story/src/alert_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl super::Story for AlertStory {
4646
"Displays a callout for user attention."
4747
}
4848

49-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
49+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
5050
Self::view(window, cx)
5151
}
5252

crates/story/src/avatar_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl super::Story for AvatarStory {
3535
"Avatar is an image that represents a user or organization."
3636
}
3737

38-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
38+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
3939
Self::view(window, cx)
4040
}
4141

crates/story/src/badge_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl super::Story for BadgeStory {
3434
"A red dot that indicates the number of unread messages."
3535
}
3636

37-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
37+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
3838
Self::view(window, cx)
3939
}
4040

crates/story/src/button_story.rs

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl super::Story for ButtonStory {
6161
false
6262
}
6363

64-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
64+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
6565
Self::view(window, cx)
6666
}
6767
}
@@ -599,8 +599,8 @@ impl Render for ButtonStory {
599599
),
600600
)
601601
.child(
602-
section(
603-
h_flex().gap_2().child("Toggle Button Group").child(
602+
section("Toggle Button Group")
603+
.sub_title(
604604
Checkbox::new("multiple-button")
605605
.text_sm()
606606
.label("Multiple")
@@ -609,41 +609,40 @@ impl Render for ButtonStory {
609609
view.toggle_multiple = !view.toggle_multiple;
610610
cx.notify();
611611
})),
612+
)
613+
.child(
614+
ButtonGroup::new("toggle-button-group")
615+
.outline()
616+
.compact()
617+
.multiple(toggle_multiple)
618+
.child(
619+
Button::new("disabled-toggle-button")
620+
.label("Disabled")
621+
.selected(disabled),
622+
)
623+
.child(
624+
Button::new("loading-toggle-button")
625+
.label("Loading")
626+
.selected(loading),
627+
)
628+
.child(
629+
Button::new("selected-toggle-button")
630+
.label("Selected")
631+
.selected(selected),
632+
)
633+
.child(
634+
Button::new("compact-toggle-button")
635+
.label("Compact")
636+
.selected(compact),
637+
)
638+
.on_click(cx.listener(|view, selected: &Vec<usize>, _, cx| {
639+
view.disabled = selected.contains(&0);
640+
view.loading = selected.contains(&1);
641+
view.selected = selected.contains(&2);
642+
view.compact = selected.contains(&3);
643+
cx.notify();
644+
})),
612645
),
613-
)
614-
.child(
615-
ButtonGroup::new("toggle-button-group")
616-
.outline()
617-
.compact()
618-
.multiple(toggle_multiple)
619-
.child(
620-
Button::new("disabled-toggle-button")
621-
.label("Disabled")
622-
.selected(disabled),
623-
)
624-
.child(
625-
Button::new("loading-toggle-button")
626-
.label("Loading")
627-
.selected(loading),
628-
)
629-
.child(
630-
Button::new("selected-toggle-button")
631-
.label("Selected")
632-
.selected(selected),
633-
)
634-
.child(
635-
Button::new("compact-toggle-button")
636-
.label("Compact")
637-
.selected(compact),
638-
)
639-
.on_click(cx.listener(|view, selected: &Vec<usize>, _, cx| {
640-
view.disabled = selected.contains(&0);
641-
view.loading = selected.contains(&1);
642-
view.selected = selected.contains(&2);
643-
view.compact = selected.contains(&3);
644-
cx.notify();
645-
})),
646-
),
647646
)
648647
.child(
649648
section("Dropdown Button")

crates/story/src/calendar_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl super::Story for CalendarStory {
2525
"A calendar to select a date or date range."
2626
}
2727

28-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
28+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
2929
Self::view(window, cx)
3030
}
3131
}

crates/story/src/chart_story.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl super::Story for ChartStory {
6868
"Beautiful Charts & Graphs."
6969
}
7070

71-
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render + Focusable> {
71+
fn new_view(window: &mut Window, cx: &mut App) -> Entity<impl Render> {
7272
Self::view(window, cx)
7373
}
7474

0 commit comments

Comments
 (0)