mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
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>
14 lines
697 B
JavaScript
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;
|
|
}
|