bootstrap-combobox icon indicating copy to clipboard operation
bootstrap-combobox copied to clipboard

Make it a real combo box

Open tflori opened this issue 1 year ago • 0 comments

Only now I found out that this jquery extension is not a real combo box but a non-editable combo box. Maybe it is just me but a combo box for me means that you can decide to enter something new: https://en.wikipedia.org/wiki/Combo_box

First I thought clearIfNoMatch: false would make it that way. At least it looks like it. But the $target value does never get updated with the entered text and gets set to empty string even when clearIfNoMatch is false.

My proposal is to update the $target value with every keup event and don't clear it as well. Here is a diff how I use it:

Index: bootstrap-combobox.js
===================================================================
diff --git a/bootstrap-combobox.js b/bootstrap-combobox.js
--- a/bootstrap-combobox.js
+++ b/bootstrap-combobox.js
@@ -403,6 +403,9 @@
                 default:
                     this.clearTarget();
                     this.lookup();
+                    if (!this.selected && !this.clearIfNoMatch) {
+                        this.$target.val(this.$element.val());
+                    }
             }
 
             e.stopPropagation();
@@ -418,10 +421,11 @@
             this.focused = false;
             var val = this.$element.val();
             if (!this.selected && val !== '' ) {
-                if(that.clearIfNoMatch)
+                if (this.clearIfNoMatch) {
                     this.$element.val('');
-                this.$source.val('').trigger('change');
-                this.$target.val('').trigger('change');
+                    this.$target.val('').trigger('change');
+                }
+                this.$source.val('').trigger('change');
             }
             if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}
         }

tflori avatar Feb 01 '23 16:02 tflori