Files
wekan/client/lib/mentionKeyGuard.js
T
Lauri OjansivuandClaude Opus 4.8 3ce75dd87b Fix #3289, #4172, #5457: Enter selects @mention instead of closing the card
When the @mention autocomplete dropdown is open in the comment/description/minicard
editor, pressing Enter to pick a highlighted user submitted the comment and closed
the card instead of selecting the mention. Hardened the shared textcomplete keydown
guard (createEscapeableTextComplete) to preventDefault + stopImmediatePropagation
while the dropdown is open, so Enter is consumed by the suggestion selection only.
Pure shouldSubmitOnEnter helper unit-tested.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 19:17:00 +03:00

14 lines
697 B
JavaScript

// Pure helper shared by the comment / description editor key handling.
//
// Regression #3289 / #4172 / #5457: when the @mention (or other textcomplete)
// autocomplete dropdown is open, pressing Enter should SELECT the highlighted
// suggestion, not submit the comment / close the card. This helper centralises
// that single decision so it can be unit-tested without a DOM.
//
// Returns true when an Enter keypress should be allowed to submit the form
// (i.e. the autocomplete dropdown is NOT open), and false when Enter must be
// captured by the autocomplete to pick the highlighted suggestion.
export function shouldSubmitOnEnter({ autocompleteOpen } = {}) {
return !autocompleteOpen;
}