Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Hide autocomplete on Enter key press instead of sending message #2968

Merged

Conversation

npny
Copy link
Contributor

@npny npny commented May 14, 2019

Fixes element-hq/element-web#4721

In handleReturn, if autocomplete is open (countCompletions > 0), then hide() it and swallow the event.

Because the autocomplete continuously edits the composer's content to match the token under selection, by simply hiding it we're left with whatever token was last selected, which is the behaviour one expects for confirmation through Enter.

Contrast this with onEscape which first resets the selection to 0 so that it goes back to the initial bare text regardless of what you had selected at the time, or with onCompletionClicked which first forces the selection of the clicked item's index, then hides (unnecessary in this case because the confirmed item is already selected).

Signed-off-by: Pierre Boyer <[email protected]>

@jryans jryans requested a review from a team May 14, 2019 12:39
@dbkr dbkr requested review from bwindels and removed request for a team May 16, 2019 16:06
@bwindels
Copy link
Contributor

Hi, thank you for your PR!

We've recently introduced a new composer for editing messages (currently under a labs flag, in src/components/views/elements/MessageEditor.js). The new editor shares the Autocomplete component with the MessageComposerInput. I'm still changing bits in the auto complete support there, so rather wait until that stabilizes to see how these changes can be merged in.

Will report back here when that's done. Thanks for your patience.

@bwindels bwindels self-assigned this May 16, 2019
@bwindels bwindels removed the blocked label May 28, 2019
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long wait, this looks good to me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing "Enter" when autocompleting should autocomplete, not send message
2 participants