diff --git a/plugins/README.md b/plugins/README.md index 25992ee2a7..e266f43f96 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -2748,6 +2748,9 @@ fn handle(view: &str, event: ViewEvent) { The page talks to the plugin's code as any web view does (`openidea.postMessage` / `onMessage`, `views::post_message("preview", …)`), and sees nothing else of the IDE, so a dialog needs no capability. Only a dialog's page has `openidea.dialog`. +The dialog gives its page the keyboard when it opens, as a tool window does when +activated. The engine doesn't let a sandboxed page focus a field before the user +types or clicks, so mark the field with `autofocus`: the first key typed goes to it. For something that stays open beside the editor without taking the keyboard, use an [overlay](#overlays) or a tool window. diff --git a/src/features/plugins/__tests__/dialogs.test.tsx b/src/features/plugins/__tests__/dialogs.test.tsx index d827a97951..abb48b2e07 100644 --- a/src/features/plugins/__tests__/dialogs.test.tsx +++ b/src/features/plugins/__tests__/dialogs.test.tsx @@ -13,22 +13,24 @@ afterEach(() => { localStorage.clear(); }); -/** Runs the bridge in a fake frame window at `search`; what it posts up and its keydown handler. */ -function bridgeAt(search: string) { +/** Runs the bridge in a fake frame window at `search`; what it posts up and its keydown handlers. */ +function bridgeAt(search: string, doc: Record = {}) { const script = /