typeahead: Fix typeahead for custom selection triggers.

Now checking for custom trigger keys will happen during `keydown`
instead of `keyup` so that if the key is printable, `preventDefault`
can prevent it from appearing in the compose box.

This fixes the case when jumping to topic, would eat up any space
or new line after the cursor, due to wrong splitting around the
cursor, which was a result of using the printable custom trigger key,
the ">", in contrast to a non printable one like Enter.

The problem was that custom trigger keys like `>` that the browser's
default behavior is to type (vs. others like RightArrow where that
isn't the case) can result in extra characters being emitted, which
is not wanted.
This commit is contained in:
N-Shar-ma 2022-02-02 13:07:15 +05:30 committed by Tim Abbott
parent cc712dbade
commit ec25310654
1 changed files with 5 additions and 4 deletions

View File

@ -376,6 +376,11 @@
}
, keydown: function (e) {
if (this.trigger_selection(e)) {
if (!this.shown) return;
e.preventDefault();
this.select(e);
}
this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
this.move(e)
}
@ -406,10 +411,6 @@
break
default:
if (this.trigger_selection(e)) {
if (!this.shown) return;
this.select(e);
}
var hideOnEmpty = false
if (e.keyCode === 8 && this.options.helpOnEmptyStrings) { // backspace
hideOnEmpty = true