Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q chat: Create a new prompt form does not autofocus or submit with Enter press"
}
23 changes: 23 additions & 0 deletions packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,29 @@ export class Connector extends BaseConnector {
)
}

onFormTextualItemKeyPress = (
tabId: string,
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
eventId?: string
) => {
if (itemId === 'prompt-name' && event.key === 'Enter') {
event.preventDefault()
this.sendMessageToExtension({
command: 'form-action-click',
action: {
id: 'submit-create-prompt',
formItemValues: formData,
},
tabType: this.getTabType(),
tabID: tabId,
})
return true
}
return false
}

handleMessageReceive = async (messageData: any): Promise<void> => {
if (messageData.type === 'chatMessage') {
await this.processChatMessage(messageData)
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,20 @@ export class Connector {
}
}

onFormTextualItemKeyPress = (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
switch (this.tabsStorage.getTab(tabId)?.type) {
case 'cwc':
return this.cwChatConnector.onFormTextualItemKeyPress(tabId, event, formData, itemId, eventId)
}
return false
}

onCustomFormAction = (
tabId: string,
messageId: string | undefined,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,15 @@ export const createMynahUI = (
onCustomFormAction: (tabId, action, eventId) => {
connector.onCustomFormAction(tabId, undefined, action, eventId)
},
onFormTextualItemKeyPress: (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
return connector.onFormTextualItemKeyPress(event, formData, itemId, tabId, eventId)
},
onChatPromptProgressActionButtonClicked: (tabID, action) => {
connector.onCustomFormAction(tabID, undefined, action)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ export class ChatController {
id: 'prompt-name',
type: 'textinput',
mandatory: true,
autoFocus: true,
title: i18n('AWS.amazonq.savedPrompts.title'),
placeholder: i18n('AWS.amazonq.savedPrompts.placeholder'),
description: i18n('AWS.amazonq.savedPrompts.description'),
Expand Down
Loading