forked from reya/gpui-native-kit
chore: reduce component overhead (#3)
Reviewed-on: reya/gpui-native-kit#3
This commit is contained in:
@@ -7,7 +7,7 @@ use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, ClickEvent, DispatchPhase, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent,
|
||||
MouseButton, MouseDownEvent, ParentElement as _, RenderOnce, Role, SharedString,
|
||||
StatefulInteractiveElement as _, Styled as _, Window, canvas, div, hsla, relative,
|
||||
StatefulInteractiveElement as _, Styled as _, Window, canvas, div, relative,
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
@@ -193,7 +193,7 @@ impl RenderOnce for DropdownMenu {
|
||||
let border = if show_border {
|
||||
colors.border
|
||||
} else {
|
||||
background.unwrap_or_else(|| hsla(0.0, 0.0, 0.0, 0.0))
|
||||
background.unwrap_or_else(gpui::transparent_black)
|
||||
};
|
||||
|
||||
let split = self.on_click.is_some();
|
||||
@@ -207,7 +207,8 @@ impl RenderOnce for DropdownMenu {
|
||||
let a11y_label = self.a11y_label.or_else(|| self.label.clone());
|
||||
let focus = focus_handle(&self.id, window, cx).tab_stop(self.tab_stop);
|
||||
// How the menu was last opened, read by the frame that mounts the panel.
|
||||
let keyboard_open = window.use_keyed_state("dropdown-open-origin", cx, |_, _| false);
|
||||
let keyboard_open =
|
||||
window.use_keyed_state((self.id.clone(), "dropdown-open-origin"), cx, |_, _| false);
|
||||
|
||||
let on_open: ChangeHandler = {
|
||||
let focus = focus.clone();
|
||||
@@ -421,10 +422,10 @@ impl RenderOnce for DropdownMenu {
|
||||
|
||||
let items = if self.open {
|
||||
self.items
|
||||
.map(|build| build(window, cx))
|
||||
.unwrap_or_default()
|
||||
.map(|build| Rc::from(build(window, cx)))
|
||||
.unwrap_or_else(|| Rc::from([]))
|
||||
} else {
|
||||
Vec::new()
|
||||
Rc::from([])
|
||||
};
|
||||
|
||||
if let Some(panel) = anchored_menu_panel(
|
||||
|
||||
Reference in New Issue
Block a user