copilot: Track focus of modal + close modal on ESC (#9217)
I've also made Copilot's modal regain focus whenever you click on it, as otherwise there's nothing inside of it that can gain focus. Clicks do not fall through a modal, which I think is nice. Release Notes: - Fixed the issue where pressing ESC (`menu::Cancel`) did not exit the Copilot modal. Fixes #8852
This commit is contained in:
parent
0a341261d0
commit
e103607134
3 changed files with 12 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2493,6 +2493,7 @@ dependencies = [
|
||||||
"fs",
|
"fs",
|
||||||
"gpui",
|
"gpui",
|
||||||
"language",
|
"language",
|
||||||
|
"menu",
|
||||||
"settings",
|
"settings",
|
||||||
"ui",
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
|
|
|
@ -19,6 +19,7 @@ editor.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
|
menu.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use copilot::{request::PromptUserDeviceFlow, Copilot, Status};
|
use copilot::{request::PromptUserDeviceFlow, Copilot, Status};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, svg, AppContext, ClipboardItem, DismissEvent, Element, EventEmitter, FocusHandle,
|
div, svg, AppContext, ClipboardItem, DismissEvent, Element, EventEmitter, FocusHandle,
|
||||||
FocusableView, InteractiveElement, IntoElement, Model, ParentElement, Render, Styled,
|
FocusableView, InteractiveElement, IntoElement, Model, MouseDownEvent, ParentElement, Render,
|
||||||
Subscription, ViewContext,
|
Styled, Subscription, ViewContext,
|
||||||
};
|
};
|
||||||
use ui::{prelude::*, Button, IconName, Label};
|
use ui::{prelude::*, Button, IconName, Label};
|
||||||
use workspace::ModalView;
|
use workspace::ModalView;
|
||||||
|
@ -185,11 +185,19 @@ impl Render for CopilotCodeVerification {
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.id("copilot code verification")
|
.id("copilot code verification")
|
||||||
|
.track_focus(&self.focus_handle)
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
.w_96()
|
.w_96()
|
||||||
.items_center()
|
.items_center()
|
||||||
.p_4()
|
.p_4()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
.on_action(cx.listener(|_, _: &menu::Cancel, cx| {
|
||||||
|
cx.emit(DismissEvent);
|
||||||
|
}))
|
||||||
|
.capture_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, cx| {
|
||||||
|
cx.focus(&this.focus_handle);
|
||||||
|
cx.stop_propagation();
|
||||||
|
}))
|
||||||
.child(
|
.child(
|
||||||
svg()
|
svg()
|
||||||
.w_32()
|
.w_32()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue