diff --git a/.changeset/prevent-editor-shortcut-newline.md b/.changeset/prevent-editor-shortcut-newline.md new file mode 100644 index 0000000..80ff767 --- /dev/null +++ b/.changeset/prevent-editor-shortcut-newline.md @@ -0,0 +1,5 @@ +--- +"@jmfederico/pi-web": patch +--- + +Prevent the message composer from inserting a stray blank line when starting a new session with the keyboard shortcut. diff --git a/src/client/src/components/PiWebApp.ts b/src/client/src/components/PiWebApp.ts index 1771fe0..3bdd0ee 100644 --- a/src/client/src/components/PiWebApp.ts +++ b/src/client/src/components/PiWebApp.ts @@ -40,6 +40,7 @@ import { appStyles } from "./shared"; type NavigationSection = "projects" | "workspaces" | "sessions"; const PI_WEB_STATUS_REFRESH_MS = 15 * 60 * 1000; +const GLOBAL_SHORTCUT_LISTENER_OPTIONS = { capture: true } as const; const THEME_AUTO_ON_VALUE = "auto:on"; const THEME_AUTO_OFF_VALUE = "auto:off"; const THEME_OPTION_PREFIX = "theme:"; @@ -150,7 +151,7 @@ export class PiWebApp extends LitElement { window.addEventListener("popstate", this.onPopState); window.addEventListener("focus", this.onFocus); document.addEventListener("visibilitychange", this.onVisibilityChange); - window.addEventListener("keydown", this.onKeyDown); + window.addEventListener("keydown", this.onKeyDown, GLOBAL_SHORTCUT_LISTENER_OPTIONS); this.mobileNavigationMedia?.addEventListener("change", this.onMobileNavigationMediaChange); this.systemLightThemeMedia?.addEventListener("change", this.onSystemLightThemeChange); this.applyPreferredTheme(false); @@ -166,7 +167,7 @@ export class PiWebApp extends LitElement { window.removeEventListener("popstate", this.onPopState); window.removeEventListener("focus", this.onFocus); document.removeEventListener("visibilitychange", this.onVisibilityChange); - window.removeEventListener("keydown", this.onKeyDown); + window.removeEventListener("keydown", this.onKeyDown, GLOBAL_SHORTCUT_LISTENER_OPTIONS); this.mobileNavigationMedia?.removeEventListener("change", this.onMobileNavigationMediaChange); this.systemLightThemeMedia?.removeEventListener("change", this.onSystemLightThemeChange); this.keyboard.reset();