-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Always focus the panel when clicked to ensure menu buttons are visible #4511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always focus the panel when clicked to ensure menu buttons are visible #4511
Conversation
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @hassoncs, Thank you for your contribution!
I tested it and it works pretty well.
Adds a new `focusPanel` command and utility function to allow focusing the active webview panel (tab or sidebar). This command is now triggered when a user clicks on non-interactive content within the webview, improving user experience by automatically bringing the panel into focus. This fixes an issue where sometimes the menu options do not appear because the panel is not in focus: https://github.com/orgs/Kilo-Org/projects/4/views/1?pane=issue&itemId=113936749&issue=Kilo-Org%7Ckilocode%7C619 **Details** - **New Command:** Introduced `focusPanel` command to programmatically focus the webview panel. - **Utility Function:** Created `src/utils/focusPanel.ts` to encapsulate the logic for revealing tab panels or focusing sidebar panels. - **Webview Integration:** Added a `focusPanelRequest` message type to `WebviewMessage` and implemented a handler in `webviewMessageHandler` to execute the new `focusPanel` command. - **User Experience:** Implemented a `useAddNonInteractiveClickListener` hook in `webview-ui` that sends a `focusPanelRequest` message to the extension when a click occurs on non-interactive elements, ensuring the webview gains focus. - **Refactor:** Modified the `focusInput` command to utilize the new `focusPanel` utility, reducing code duplication and centralizing panel focus logic.
99bd5b1 to
c4ab5bd
Compare
|
@daniel-lxs, thank you for the quick review! I made one small change to add a could you re-approve when you get a chance? I accidentally force-pushed, sorry about that! |
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again!
|
@daniel-lxs were you able to repro this issue? I don't believe I've seen it before, but maybe I just didn't notice... |
|
Note the the bug was only reproducible in the popped-out version of the Sidebar. The buttons are always visible in the main version. |
Ahh got it. I don't usually run it popped out so makes sense that I haven't seen it. |
|
@mrubens |
Related GitHub Issue
Kilo-Org/kilocode#619
Description
This fixes an issue where sometimes the menu options do not appear because the panel is not in focus: Kilo-Org/kilocode#619
Adds a new
focusPanelcommand and utility function to allow focusing the active webview panel (tab or sidebar). This command is now triggered when a user clicks on any non-interactive content within the webview, improving user experience by automatically bringing the panel into focus.Previously clicking the panel would sometimes focus it, sometimes not:

Details
focusPanelcommand to programmatically focus the webview panel.src/utils/focusPanel.tsto encapsulate the logic for revealing tab panels or focusing sidebar panels.focusPanelRequestmessage type toWebviewMessageand implemented a handler inwebviewMessageHandlerto execute the newfocusPanelcommand.useAddNonInteractiveClickListenerhook inwebview-uithat sends afocusPanelRequestmessage to the extension when a click occurs on non-interactive elements, ensuring the webview gains focus.focusInputcommand to utilize the newfocusPanelutility, reducing code duplication and centralizing panel focus logic.Test Procedure
For both the sidebar and popped-out sidebar, I verified clicking now always focused the panel. Also verified the focusInput functionality is still working properly
Type of Change
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
Important
Adds
focusPanelcommand and utility to ensure webview panel focus on click, with supporting changes in message handling and UI hooks.focusPanelcommand to focus webview panel when clicked.focusPanelRequestmessage inwebviewMessageHandler.tsto triggerfocusPanelcommand.useAddNonInteractiveClickListenerhook inApp.tsxto sendfocusPanelRequeston non-interactive clicks.focusPanel.tsto centralize panel focusing logic.focusInputcommand inregisterCommands.tsto usefocusPanelutility.focusPanelRequesttoWebviewMessagetype inWebviewMessage.ts.This description was created by
for 99bd5b1ee8ac221c4acce5863983e728dff47ae6. You can customize this summary. It will automatically update as commits are pushed.