FIX: allows paste from context menu to work (#14061)

- uses keyDown for Enter event
- input for other keys and pasting
This commit is contained in:
Joffrey JAFFEUX 2021-08-17 13:20:34 +02:00 committed by GitHub
parent ecb117df59
commit c65822d47b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import { searchContextDescription } from "discourse/lib/search";
createWidget("search-term", { createWidget("search-term", {
tagName: "input", tagName: "input",
buildId: () => "search-term", buildId: () => "search-term",
buildKey: () => `search-term`, buildKey: () => "search-term",
defaultState() { defaultState() {
return { afterAutocomplete: false }; return { afterAutocomplete: false };
@ -23,12 +23,15 @@ createWidget("search-term", {
}; };
}, },
keyUp(e) { keyDown(e) {
if (e.which === 13 && !this.state.afterAutocomplete) { if (e.key === "Enter" && !this.state.afterAutocomplete) {
return this.sendWidgetAction("fullSearch"); return this.sendWidgetAction("fullSearch");
} }
},
input(e) {
const val = this.attrs.value; const val = this.attrs.value;
// remove zero-width chars // remove zero-width chars
const newVal = e.target.value.replace(/[\u200B-\u200D\uFEFF]/, ""); const newVal = e.target.value.replace(/[\u200B-\u200D\uFEFF]/, "");