1
0
Эх сурвалжийг харах

ignore key events on input fields

Falko Schindler 3 жил өмнө
parent
commit
c18d5ef479

+ 5 - 0
nicegui/elements/keyboard.js

@@ -3,6 +3,11 @@ Vue.component("keyboard", {
   mounted() {
     for (const event of this.$props.jp_props.options.activeJSEvents) {
       document.addEventListener(event, (evt) => {
+        // https://stackoverflow.com/a/36469636/3419103
+        const ignored = ["input", "select", "button", "textarea"];
+        const focus = document.activeElement;
+        if (focus && ignored.includes(focus.tagName.toLowerCase())) return;
+
         const e = {
           event_type: "keyboardEvent",
           id: this.$props.jp_props.id,