Skip to content

Commit 1c778df

Browse files
committed
remove ctrl/cmd+enter key functionality as it isn't working consistently
1 parent 7a05a23 commit 1c778df

File tree

1 file changed

+7
-34
lines changed

1 file changed

+7
-34
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -266,27 +266,6 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
266266
[isModifierPressed],
267267
)
268268

269-
// Handle keyboard events on mentions for accessibility
270-
const handleMentionKeyDown = useCallback(
271-
(e: KeyboardEvent) => {
272-
if (!isModifierPressed) return
273-
274-
const target = e.target as HTMLElement
275-
if (target.tagName === "MARK" && target.classList.contains("mention-context-textarea-highlight")) {
276-
if (e.key === "Enter" || e.key === " ") {
277-
e.preventDefault()
278-
const mentionText = target.textContent
279-
if (mentionText) {
280-
// Remove @ symbol if present and send to VSCode
281-
const cleanText = mentionText.startsWith("@") ? mentionText.slice(1) : mentionText
282-
vscode.postMessage({ type: "openMention", text: cleanText })
283-
}
284-
}
285-
}
286-
},
287-
[isModifierPressed],
288-
)
289-
290269
// Fetch git commits when Git is selected or when typing a hash.
291270
useEffect(() => {
292271
if (selectedType === ContextMenuOptionType.Git || /^[a-f0-9]+$/i.test(searchQuery)) {
@@ -785,19 +764,15 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
785764

786765
// Determine the class to use based on modifier key state
787766
const mentionClass = `mention-context-textarea-highlight${isModifierPressed ? " clickable" : ""}`
788-
const tabIndex = isModifierPressed ? 0 : -1
789-
const ariaLabel = isModifierPressed
790-
? `${isMac ? "Cmd" : "Ctrl"} + Click or Enter to open`
767+
const tooltipText = isModifierPressed
768+
? `${isMac ? "Cmd" : "Ctrl"} + Click to open`
791769
: `Hold ${isMac ? "Cmd" : "Ctrl"} + Click to open`
792770

793771
// Process the text to highlight mentions and valid commands
794772
let processedText = text
795773
.replace(/\n$/, "\n\n")
796774
.replace(/[<>&]/g, (c) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;" })[c] || c)
797-
.replace(
798-
mentionRegexGlobal,
799-
`<mark class="${mentionClass}" tabindex="${tabIndex}" role="button" aria-label="${ariaLabel}" title="${ariaLabel}">$&</mark>`,
800-
)
775+
.replace(mentionRegexGlobal, `<mark class="${mentionClass}" title="${tooltipText}">$&</mark>`)
801776

802777
// Custom replacement for commands - only highlight valid ones
803778
processedText = processedText.replace(commandRegexGlobal, (match, commandName) => {
@@ -809,10 +784,10 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
809784

810785
if (startsWithSpace) {
811786
// Keep the space but only highlight the command part
812-
return ` <mark class="${mentionClass}" tabindex="${tabIndex}" role="button" aria-label="${ariaLabel}" title="${ariaLabel}">${commandPart}</mark>`
787+
return ` <mark class="${mentionClass}" title="${tooltipText}">${commandPart}</mark>`
813788
} else {
814789
// Highlight the entire command (starts at beginning of line)
815-
return `<mark class="${mentionClass}" tabindex="${tabIndex}" role="button" aria-label="${ariaLabel}" title="${ariaLabel}">${commandPart}</mark>`
790+
return `<mark class="${mentionClass}" title="${tooltipText}">${commandPart}</mark>`
816791
}
817792
}
818793
return match // Return unhighlighted if command is not valid
@@ -828,18 +803,16 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
828803
updateHighlights()
829804
}, [inputValue, updateHighlights])
830805

831-
// Add click and keyboard event listeners to highlight layer for mention interactions
806+
// Add click event listener to highlight layer for mention clicks
832807
useEffect(() => {
833808
const highlightLayer = highlightLayerRef.current
834809
if (highlightLayer) {
835810
highlightLayer.addEventListener("click", handleMentionClick)
836-
highlightLayer.addEventListener("keydown", handleMentionKeyDown)
837811
return () => {
838812
highlightLayer.removeEventListener("click", handleMentionClick)
839-
highlightLayer.removeEventListener("keydown", handleMentionKeyDown)
840813
}
841814
}
842-
}, [handleMentionClick, handleMentionKeyDown])
815+
}, [handleMentionClick])
843816

844817
const updateCursorPosition = useCallback(() => {
845818
if (textAreaRef.current) {

0 commit comments

Comments
 (0)