diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 681899b3..797af910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,14 +3,17 @@ on: pull_request: push: branches: - - "*" + - main tags: - "*" +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} + cancel-in-progress: true + jobs: test: name: Test - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name strategy: fail-fast: false matrix: diff --git a/crates/story/src/menu_story.rs b/crates/story/src/menu_story.rs index 74bcfa97..15b0d5c8 100644 --- a/crates/story/src/menu_story.rs +++ b/crates/story/src/menu_story.rs @@ -1,7 +1,6 @@ use gpui::{ - Action, App, AppContext, Context, Corner, Entity, FocusHandle, Focusable, InteractiveElement, - IntoElement, KeyBinding, ParentElement as _, Render, SharedString, Styled as _, Window, - actions, div, px, + Action, App, AppContext, Context, Corner, Entity, InteractiveElement, IntoElement, KeyBinding, + ParentElement as _, Render, SharedString, Styled as _, Window, actions, div, px, }; use gpui_component::{ ActiveTheme as _, IconName, button::Button, context_menu::ContextMenuExt, h_flex, @@ -40,7 +39,6 @@ pub fn init(cx: &mut App) { } pub struct MenuStory { - focus_handle: FocusHandle, checked: bool, message: String, } @@ -64,12 +62,9 @@ impl MenuStory { cx.new(|cx| Self::new(window, cx)) } - fn new(window: &mut Window, cx: &mut Context) -> Self { - cx.focus_self(window); - + fn new(_: &mut Window, _: &mut Context) -> Self { Self { checked: true, - focus_handle: cx.focus_handle(), message: "".to_string(), } } @@ -106,19 +101,12 @@ impl MenuStory { } } -impl Focusable for MenuStory { - fn focus_handle(&self, _cx: &App) -> FocusHandle { - self.focus_handle.clone() - } -} - impl Render for MenuStory { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { let checked = self.checked; v_flex() .key_context(CONTEXT) - .track_focus(&self.focus_handle) .on_action(cx.listener(Self::on_copy)) .on_action(cx.listener(Self::on_cut)) .on_action(cx.listener(Self::on_paste)) diff --git a/crates/ui/src/menu/app_menu_bar.rs b/crates/ui/src/menu/app_menu_bar.rs index 882c5a33..fdeaf771 100644 --- a/crates/ui/src/menu/app_menu_bar.rs +++ b/crates/ui/src/menu/app_menu_bar.rs @@ -141,7 +141,10 @@ impl AppMenu { None => { let items = self.menu.items.clone(); let popup_menu = PopupMenu::build(window, cx, |menu, window, cx| { - menu.with_menu_items(items, window, cx) + menu.when_some(window.focused(cx), |this, handle| { + this.action_context(handle) + }) + .with_menu_items(items, window, cx) }); popup_menu.read(cx).focus_handle(cx).focus(window); self._subscription = diff --git a/crates/ui/src/menu/popup_menu.rs b/crates/ui/src/menu/popup_menu.rs index a2e337fe..32911656 100644 --- a/crates/ui/src/menu/popup_menu.rs +++ b/crates/ui/src/menu/popup_menu.rs @@ -164,11 +164,7 @@ impl PopupMenu { cx: &mut App, f: impl FnOnce(Self, &mut Window, &mut Context) -> Self, ) -> Entity { - cx.new(|cx| { - let mut menu = Self::new(cx); - menu.action_context = window.focused(cx); - f(menu, window, cx) - }) + cx.new(|cx| f(Self::new(cx), window, cx)) } /// Set the focus handle of Entity to handle actions. @@ -661,10 +657,8 @@ impl PopupMenu { window: &mut Window, cx: &mut Context, ) { - if let Some(action_context) = self.action_context.as_ref() { - if !action_context.contains_focused(window, cx) { - action_context.focus(window); - } + if let Some(context) = self.action_context.as_ref() { + context.focus(window); } window.dispatch_action(action.boxed_clone(), cx);