Better Suggestion Menu triggering in Connector

This commit is contained in:
NI
2020-07-16 11:47:52 +08:00
parent 7d2e5491d9
commit bd4ef796a9

View File

@@ -76,7 +76,7 @@
:autofocus="field.autofocus" :autofocus="field.autofocus"
:tabindex="field.tabIndex" :tabindex="field.tabIndex"
:disabled="field.field.readonly" :disabled="field.field.readonly"
@keydown="keydown($event, key, field)" @keydown="triggerSuggestions($event, key, field)"
@focus="focus(key, field, true)" @focus="focus(key, field, true)"
@blur="focus(key, field, false)" @blur="focus(key, field, false)"
@input="changed(key, field, false)" @input="changed(key, field, false)"
@@ -126,11 +126,13 @@
:autofocus="field.autofocus" :autofocus="field.autofocus"
:tabindex="field.tabIndex" :tabindex="field.tabIndex"
:disabled="field.field.readonly" :disabled="field.field.readonly"
@keydown="keydown(key, field)" @keyup="expandTextarea($event)"
@keydown="
triggerSuggestions($event, key, field) || expandTextarea($event)
"
@focus="focus(key, field, true)" @focus="focus(key, field, true)"
@blur="focus(key, field, false)" @blur="focus(key, field, false)"
@input="changed(key, field, false)" @input="changed(key, field, false)"
@keyup="expandTextarea"
@change="changed(key, field, true)" @change="changed(key, field, true)"
></textarea> ></textarea>
@@ -311,7 +313,7 @@ function buildEmptyCurrent() {
actionText: "Continue", actionText: "Continue",
cancellable: false, cancellable: false,
submittable: false, submittable: false,
submitting: false submitting: false,
}; };
} }
@@ -324,14 +326,14 @@ export default {
} }
el.focus(); el.focus();
} },
} },
}, },
props: { props: {
connector: { connector: {
type: Object, type: Object,
default: () => null default: () => null,
} },
}, },
data() { data() {
return { return {
@@ -343,7 +345,7 @@ export default {
submitterTabIndex: 1, submitterTabIndex: 1,
working: false, working: false,
disabled: false, disabled: false,
cancelled: false cancelled: false,
}; };
}, },
watch: { watch: {
@@ -355,7 +357,7 @@ export default {
this.cancelled = false; this.cancelled = false;
this.currentConnector = newV; this.currentConnector = newV;
this.runWizard(); this.runWizard();
} },
}, },
async mounted() { async mounted() {
await this.closeWizard(); await this.closeWizard();
@@ -487,10 +489,7 @@ export default {
this.preloaderIDName = this.preloaderIDName =
preloaderIDPrefix + preloaderIDPrefix +
this.getConnector() this.getConnector().wizard.control().ui().toLowerCase();
.wizard.control()
.ui()
.toLowerCase();
this.currentConnectorCloseWait = (async () => { this.currentConnectorCloseWait = (async () => {
while (!this.disabled) { while (!this.disabled) {
@@ -560,7 +559,9 @@ export default {
} }
}, },
expandTextarea(event) { expandTextarea(event) {
event.target.style.overflowY = "hidden"; // WARNING: This function may cause rendering stutter due to
// combined problem of CSS "Position" and Vue render.
// Use of "TextArea" element is thus not recommended.
event.target.style.height = ""; event.target.style.height = "";
event.target.style.height = event.target.scrollHeight + "px"; event.target.style.height = event.target.scrollHeight + "px";
}, },
@@ -706,7 +707,7 @@ export default {
this.verify(key, field, force); this.verify(key, field, force);
}, },
keydown(event, key, field) { triggerSuggestions(event, key, field) {
switch (event.key) { switch (event.key) {
case "ArrowUp": case "ArrowUp":
event.preventDefault(); event.preventDefault();
@@ -825,7 +826,7 @@ export default {
this.current.submitting = true; this.current.submitting = true;
await this.current.data.cancel(); await this.current.data.cancel();
} },
} },
}; };
</script> </script>