fix: pr-bug-scan validated finding from #1893 (#1966)

Co-authored-by: orca-bug-scan-bot <orca-bug-scan-bot@stably.ai>
This commit is contained in:
buf0-bot[bot] 2026-05-15 16:56:18 -07:00 committed by GitHub
parent 97f276cea8
commit 7ffec887f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View File

@ -232,7 +232,16 @@ export function createRichMarkdownKeyHandler(
return false
}
const currentFilteredSlashCommands = ctx.filteredSlashCommandsRef.current
if (!event.metaKey && !event.ctrlKey && !event.altKey && event.key.length === 1) {
// Why: when the current query has no matching commands the slash menu UI
// is already hidden; intercepting further keystrokes would silently
// swallow them. Fall through so ProseMirror inserts the character and
// syncSlashMenu refreshes the query from the document.
if (currentFilteredSlashCommands.length === 0) {
return false
}
event.preventDefault()
ctx.setSlashMenu((menu) => (menu ? { ...menu, query: `${menu.query}${event.key}` } : menu))
ctx.setSelectedCommandIndex(0)
@ -246,7 +255,6 @@ export function createRichMarkdownKeyHandler(
return true
}
const currentFilteredSlashCommands = ctx.filteredSlashCommandsRef.current
if (currentFilteredSlashCommands.length === 0) {
return false
}