Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(web): move ChatView's keyboard shortcuts into a command map #20393

Mergedjuliusmarmingemerged 1 commit intochatview-split/provider-identity fromrefs/pull/20393/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 181 additions and 0 deletions (loading 4).

x
0 of 6 viewed, 6 left
75 additions and 0 deletionsapps/web/src/components/chat/composerFocusRedirect.tsAdded
View file
@@ -0,0 +1,75 @@
+// Type-to-focus: printable keys and pastes that land on no editable target go to
+// the composer, so the user can start typing anywhere in the chat.
+​
+export const TYPE_TO_FOCUS_EDITABLE_SELECTOR = [
+ "input",
+ "textarea",
+ "select",
+ '[contenteditable="true"]',
+ '[contenteditable="plaintext-only"]',
+ '[role="textbox"]',
+].join(",");
+const TYPE_TO_FOCUS_INTERACTIVE_SELECTOR = [
+ "button",
+ "a[href]",
+ "summary",
+ '[role="button"]',
+ '[role="checkbox"]',
+ '[role="menuitem"]',
+ '[role="option"]',
+ '[role="radio"]',
+ '[role="switch"]',
+ '[role="tab"]',
+].join(",");
+// Popups match only while open or closing: some stay mounted when closed,
+// such as the chat header actions menu.
+export const TYPE_TO_FOCUS_FLOATING_LAYER_SELECTOR = [
+ '[role="dialog"][aria-modal="true"]',
+ '[data-slot="alert-dialog-popup"]:is([data-open],[data-ending-style])',
+ '[data-slot="command-dialog-popup"]:is([data-open],[data-ending-style])',
+ '[data-slot="dialog-popup"]:is([data-open],[data-ending-style])',