Skip to content

Commit eb74c91

Browse files
committed
feat: Enhance focus behavior for WebView based on render context
1 parent 1e80a04 commit eb74c91

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/utils/focusPanel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function focusPanel(
1717
if (!panel) {
1818
// If no panel is open, open the sidebar
1919
await vscode.commands.executeCommand(`workbench.view.extension.${Package.name}-ActivityBar`)
20-
} else if (panel === tabPanel) {
20+
} else if (panel === tabPanel && !panel.active) {
2121
// For tab panels, use reveal to focus
2222
panel.reveal(vscode.ViewColumn.Active, false)
2323
} else if (panel === sidebarPanel) {

webview-ui/src/App.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const App = () => {
4343
experiments,
4444
cloudUserInfo,
4545
cloudIsAuthenticated,
46+
renderContext,
4647
} = useExtensionState()
4748

4849
// Create a persistent state manager
@@ -136,11 +137,14 @@ const App = () => {
136137
// Tell the extension that we are ready to receive messages.
137138
useEffect(() => vscode.postMessage({ type: "webviewDidLaunch" }), [])
138139

139-
// Focus the WebView when non-interactive content is clicked
140+
// Focus the WebView when non-interactive content is clicked (only in editor/tab mode)
140141
useAddNonInteractiveClickListener(
141142
useCallback(() => {
142-
vscode.postMessage({ type: "focusPanelRequest" })
143-
}, []),
143+
// Only send focus request if we're in editor (tab) mode, not sidebar
144+
if (renderContext === "editor") {
145+
vscode.postMessage({ type: "focusPanelRequest" })
146+
}
147+
}, [renderContext]),
144148
)
145149

146150
if (!didHydrateState) {

0 commit comments

Comments
 (0)