If you’ve ever used a tagging interface in a web application, you’re probably familiar with the “chip” interface. Examples abound (AngularJS Material, Materialize, and the tags on StackOverflow, to name a few).
We wanted to use chips in a qooxdoo application, so we had to roll our own component.
There are lots of other features I could imagine adding:
- more configurability for the chips’ appearance, including changing background color, radius, and the “delete” button image
- removing the delete buttons from the chips
- better control over the position of the input cursor and width of the suggestions dropdown
- more interesting developer-specified filtering of the suggestions list
- better keyboard control — backspace to delete chips, arrow keys to move between the chips and insert text
But I think there’s enough here to make it worth sharing.
Paste this code into the qooxdoo playground.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
qx.Class.define ("diesel.ctl.chip", { extend: qx.ui.container.Composite, construct: function (data, caption) { var l = new qx.ui.layout.Atom(); l.setGap (4); console.log ('[diesel.ctl.chip constructor] this: ', this); this.base (arguments); this._setLayout (l); this.__init (); if (typeof data !== "undefined") { this.setData (data); } if (typeof caption !== "undefined") { this.setCaption (caption); } }, events: { deleteClicked: "qx.event.type.Event" }, properties: { data: { init: null }, caption: { check: "String", init: '', apply: "applyCaption" } }, members: { __l_caption: null, __btn_delete: null, applyCaption: function (value) { this.__l_caption.setValue (value); }, on_btn_delete_click: function () { this.fireEvent ('deleteClicked'); }, __init: function () { this.setPaddingLeft (8); this.setPaddingRight (4); var d = new qx.ui.decoration.Decorator ().set ({ backgroundColor: '#ccf', radius: 4 }); this.set ({decorator: d}); var o = new qx.ui.basic.Label (''); o.setValue (this.getCaption ()); this.add (o); this.__l_caption = o; // high-res "x" button image o = new qx.ui.basic.Image ("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAdVBMVEUAAACSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrWSkrX5qU1HAAAAJnRSTlMAAQIDBAUGBwgRFRYZGiEjQ3l7hYaqtLm8vsDFx87a4uvv8fP1+bbY9ZEAAACUSURBVBgZ7cELEoIgFAXQa5BFX0srjD5Udve/xHg6TjPAEjwHk9jmeURPn22J1LYjGwTakfcSMf1h0ADaMbggpjxFXTqKExLGU3wprELKeI6sQo7xHFiFvD173Rx52nFQI0s7jmpk6Bv/GiSKG4XdeYoDYkuKVsF4Bg8kKpJXBcB48r1CqmKrIIx/rZGzKDCYKUwiP90zFUbRdHbzAAAAAElFTkSuQmCC"); o.set ({ scale: true, width: 16, height: 16 }); o.addListener ("click", this.on_btn_delete_click, this); this.add (o); this.__btn_delete = o; } } }); qx.Class.define ("diesel.ctl.AutoVirtualComboBox", { extend: qx.ui.form.VirtualComboBox, properties: { matchAtStart : { check: "Boolean", apply: "applyCheckAtStart" } }, events : { newValueEntered : "qx.event.type.Data", valueSelected : "qx.event.type.Data" }, members: { __as_textfield: null, __as_dropdown: null, __checkAtStart: false, applyCheckAtStart: function (value) { this.__checkAtStart = value; }, update_dropdown_contents: function () { var tf_val = this.__as_textfield.getValue ().trim ().toLowerCase (); // is it the right thing to do to keep replacing the delegate on every keystroke? We keep using // the same function, so in theory, if we could just trigger the delegate, we could avoid replacing // the delegate over and over; then again, we only have to compute tf_val once this way, instead // of having to compute it for every row in the model. // This is a hack -- in order to get the label associated with each object in the data model, // we have to use the labelPath; the data object doesn't have a function like data.getLabel(). But // if you know the label path (e.g. "foo"), you can find the label string in $$user_foo... You probably // shouldn't be actually referencing that directly, but it works... var prop = "$$user_" + this.getLabelPath (); this.setDelegate ({ filter: function (data) { if (tf_val === '') { return true; } if (this.__checkAtStart) { return data[prop].trim ().toLowerCase ().indexOf (tf_val) === 0; } return data[prop].trim ().toLowerCase ().indexOf (tf_val) >= 0; } }); }, _on_textfield_input: function (e) { this.open (); this.update_dropdown_contents (); }, _on_changeValue: function (e) { var newval = e.getData ().trim ().toLowerCase (); var model = this.getModel (); // see note above about hacking by using the $$user_FOO property directly var prop = "$$user_" + this.getLabelPath (); for (var i = 0; i < model.length; i++) { var data = model.getItem (i); if (data[prop].trim().toLowerCase() == newval) { this.fireDataEvent ("valueSelected", data); return; } } this.fireDataEvent ("newValueEntered", e.getData()); }, // overridden from ComboBox.js to not add the button control _createChildControlImpl: function (id, hash) { var control; switch (id) { case "button": // create the button even though we aren't going to add it, because the parent class // is probably full of references to this button and we don't want to break those. control = new qx.ui.form.Button (); control.setFocusable (false); control.setKeepActive (true); control.addState ("inner"); control.addListener ("execute", this.toggle, this); //this._add(control); break; } return control || this.base (arguments, id); } }, construct: function () { this.base (arguments); this.__as_textfield = this.getChildControl ("textfield"); this.__as_textfield.addListener ('input', this._on_textfield_input, this); this.addListener ('changeValue', this._on_changeValue, this); var d = new qx.ui.decoration.Decorator ().set ({ width: 0 }); this.__as_textfield.setDecorator (d); this.__as_dropdown = this.getChildControl ("dropdown"); } }); qx.Class.define ("diesel.ctl.chipbox", { extend: qx.ui.container.Composite, construct: function (values) { this.base (arguments, new qx.ui.layout.Canvas ()); this.__init (); if (typeof values !== 'undefined') { this.setChips (values); } }, events : { newValueEntered : "qx.event.type.Data", valueSelected: "qx.event.type.Data", changeValue : "qx.event.type.Data", chipAdded : "qx.event.type.Data", chipRemoved : "qx.event.type.Data" }, properties : { }, members: { __text_box: null, __chip_board: null, __chips: [], __combobox: null, __ignore_combobox_changeValue: false, setChips: function (values) { var i; this.__chip_board.removeAll (); this.__chips = []; for (i = 0; i < values.length; i++) { var c = this.__create_chip (values[i].data, values[i].caption); this.__chips.push (c); this.__chip_board.add (c); } if (this.__combobox !== null) { this.__chip_board.add (this.__combobox); } }, addChip: function (data, caption) { var c; var str_data = JSON.stringify (data); for (var i = 0; i < this.__chips.length; i++) { c = this.__chips[i]; if (JSON.stringify (c.getData ()) === str_data) { this.cancelChipAdd (); return; } } c = this.__create_chip (data, caption); if (this.__combobox !== null) { this.__chip_board.remove (this.__combobox); } this.__chips.push (c); this.__chip_board.add (c); if (this.__combobox !== null) { this.__ignore_combobox_changeValue = true; this.__combobox.setValue (''); this.__combobox.update_dropdown_contents (); this.__chip_board.add (this.__combobox); this.__ignore_combobox_changeValue = false; } this.fireDataEvent ("chipAdded", { value: c.getData () }); }, cancelChipAdd: function () { this.__ignore_combobox_changeValue = true; this.__combobox.setValue (''); this.__combobox.update_dropdown_contents (); this.__ignore_combobox_changeValue = false; }, setSuggestions: function (suggestions, label_path) { var model = qx.data.marshal.Json.createModel(suggestions); this.__combobox.setLabelPath (label_path); this.__combobox.setModel (model); }, _on_combobox_newValueEntered: function (e) { if (this.__ignore_combobox_changeValue) { return; } this.fireDataEvent ('newValueEntered', e.getData ()); }, _on_combobox_valueSelected: function (e) { if (this.__ignore_combobox_changeValue) { return; } this.fireDataEvent ('valueSelected', e.getData ()); }, __remove_chip: function (c) { this.__chip_board.remove (c); var new_chips = []; for (var i = 0; i < this.__chips.length; i++) { if (this.__chips[i] !== c) { new_chips.push (this.__chips[i]); } } this.__chips = new_chips; this.fireDataEvent ("chipRemoved", { value: c.getData () }); }, __create_chip: function (data, caption) { var c = new diesel.ctl.chip (data, caption); c.addListener ("deleteClicked", function () { this.__remove_chip (c); }, this); return c; }, __create_combobox: function () { if (this.__combobox !== null) { this.__chip_board.remove (this.__combobox); } o = new diesel.ctl.AutoVirtualComboBox (); o.addListener ('click', function (e) { // we need this in order to keep a click on the combobox from triggering the click event // on the chipboard, which would put the focus into the combobox, closing the popup! e.stopPropagation (); }); o.addListener ('newValueEntered', this._on_combobox_newValueEntered, this); o.addListener ('valueSelected', this._on_combobox_valueSelected, this); o.set ({width: 200}); var d = new qx.ui.decoration.Decorator ().set ({ width: 0 }); o.setDecorator (d); this.__chip_board.add (o); this.__combobox = o; }, __init: function () { var d = new qx.ui.decoration.Decorator ().set ({ color: '#000', width: 1 }); this.setDecorator (d); var l = new qx.ui.layout.Flow (); l.set ({ spacingX: 4, spacingY: 4 }); var o = new qx.ui.container.Composite (l); this.add (o, {left: 4, top: 4, right: 4, bottom: 4}); this.__chip_board = o; this.__chip_board.addListener ('click', function (e) { if (this.__combobox !== null) { this.__combobox.focus (); } }, this); this.__create_combobox (); } } }); /** * ------------------------------------------------------------ * * ------------------------------------------------------------ */ function on_cb_newValueEntered (e) { var value = e.getData ().trim (); console.log ("[on_cb_value_entered] value: " + value); if (value !== '') { console.log ("[on_cb_value_entered] adding chip; value: " + value); cb.addChip ({ id: 0, canonical: 0, tag_caption: value, canonical_caption: "" }, value); } else { console.log ("[on_cb_value_entered] cancel adding chip..."); cb.cancelChipAdd (); } } function on_cb_valueSelected (e) { var data = e.getData (); var newdata; if (data.getCanonical () == 1) { newdata = { id: data.getId (), canonical: data.getCanonical (), tag_caption: data.getTag_caption (), canonical_caption: data.getCanonical_caption () }; } else { var canonical_caption = data.getCanonical_caption (); console.log ('[on_cb_valueSelected] looking for canonical form "' + canonical_caption + '"'); newdata = canonical_forms[canonical_caption]; } console.log ("[on_cb_value_entered] adding chip; data: " + JSON.stringify (newdata)); cb.addChip (newdata, newdata.tag_caption); } var canonical_forms = []; function load_cb_suggestions () { var data = [ { id: 1, canonical: 1, tag_caption: "Alabama", canonical_caption: "" }, { id: 2, canonical: 0, tag_caption: "AL", canonical_caption: "Alabama" }, { id: 3, canonical: 1, tag_caption: "Alaska", canonical_caption: "" }, { id: 4, canonical: 0, tag_caption: "AK", canonical_caption: "Alaska" }, { id: 5, canonical: 1, tag_caption: "Arizona", canonical_caption: "" }, { id: 6, canonical: 0, tag_caption: "AZ", canonical_caption: "Arizona" }, { id: 7, canonical: 1, tag_caption: "Arkansas", canonical_caption: "" }, { id: 8, canonical: 0, tag_caption: "AR", canonical_caption: "Arkansas" }, { id: 9, canonical: 1, tag_caption: "California", canonical_caption: "" }, { id: 10, canonical: 0, tag_caption: "CA", canonical_caption: "California" }, { id: 11, canonical: 1, tag_caption: "Colorado", canonical_caption: "" }, { id: 12, canonical: 0, tag_caption: "CO", canonical_caption: "Colorado" }, { id: 13, canonical: 1, tag_caption: "Connecticut", canonical_caption: "" }, { id: 14, canonical: 0, tag_caption: "CT", canonical_caption: "Connecticut" }, { id: 15, canonical: 1, tag_caption: "Delaware", canonical_caption: "" }, { id: 16, canonical: 0, tag_caption: "DE", canonical_caption: "Delaware" }, { id: 17, canonical: 1, tag_caption: "District of Columbia", canonical_caption: "" }, { id: 18, canonical: 0, tag_caption: "DC", canonical_caption: "District of Columbia" }, { id: 19, canonical: 1, tag_caption: "Florida", canonical_caption: "" }, { id: 20, canonical: 0, tag_caption: "FL", canonical_caption: "Florida" }, { id: 21, canonical: 1, tag_caption: "Georgia", canonical_caption: "" }, { id: 22, canonical: 0, tag_caption: "GA", canonical_caption: "Georgia" }, { id: 23, canonical: 1, tag_caption: "Hawaii", canonical_caption: "" }, { id: 24, canonical: 0, tag_caption: "HI", canonical_caption: "Hawaii" }, { id: 25, canonical: 1, tag_caption: "Idaho", canonical_caption: "" }, { id: 26, canonical: 0, tag_caption: "ID", canonical_caption: "Idaho" }, { id: 27, canonical: 1, tag_caption: "Illinois", canonical_caption: "" }, { id: 28, canonical: 0, tag_caption: "IL", canonical_caption: "Illinois" }, { id: 29, canonical: 1, tag_caption: "Indiana", canonical_caption: "" }, { id: 30, canonical: 0, tag_caption: "IN", canonical_caption: "Indiana" }, { id: 31, canonical: 1, tag_caption: "Iowa", canonical_caption: "" }, { id: 32, canonical: 0, tag_caption: "IA", canonical_caption: "Iowa" }, { id: 33, canonical: 1, tag_caption: "Kansas", canonical_caption: "" }, { id: 34, canonical: 0, tag_caption: "KS", canonical_caption: "Kansas" }, { id: 35, canonical: 1, tag_caption: "Kentucky", canonical_caption: "" }, { id: 36, canonical: 0, tag_caption: "KY", canonical_caption: "Kentucky" }, { id: 37, canonical: 1, tag_caption: "Louisiana", canonical_caption: "" }, { id: 38, canonical: 0, tag_caption: "LA", canonical_caption: "Louisiana" }, { id: 39, canonical: 1, tag_caption: "Maine", canonical_caption: "" }, { id: 40, canonical: 0, tag_caption: "ME", canonical_caption: "Maine" }, { id: 41, canonical: 1, tag_caption: "Montana", canonical_caption: "" }, { id: 42, canonical: 0, tag_caption: "MT", canonical_caption: "Montana" }, { id: 43, canonical: 1, tag_caption: "Nebraska", canonical_caption: "" }, { id: 44, canonical: 0, tag_caption: "NE", canonical_caption: "Nebraska" }, { id: 45, canonical: 1, tag_caption: "Nevada", canonical_caption: "" }, { id: 46, canonical: 0, tag_caption: "NV", canonical_caption: "Nevada" }, { id: 47, canonical: 1, tag_caption: "New Hampshire", canonical_caption: "" }, { id: 48, canonical: 0, tag_caption: "NH", canonical_caption: "New Hampshire" }, { id: 49, canonical: 1, tag_caption: "New Jersey", canonical_caption: "" }, { id: 50, canonical: 0, tag_caption: "NJ", canonical_caption: "New Jersey" }, { id: 51, canonical: 1, tag_caption: "New Mexico", canonical_caption: "" }, { id: 52, canonical: 0, tag_caption: "NM", canonical_caption: "New Mexico" }, { id: 53, canonical: 1, tag_caption: "New York", canonical_caption: "" }, { id: 54, canonical: 0, tag_caption: "NY", canonical_caption: "New York" }, { id: 55, canonical: 1, tag_caption: "North Carolina", canonical_caption: "" }, { id: 56, canonical: 0, tag_caption: "NC", canonical_caption: "North Carolina" }, { id: 57, canonical: 1, tag_caption: "North Dakota", canonical_caption: "" }, { id: 58, canonical: 0, tag_caption: "ND", canonical_caption: "North Dakota" }, { id: 59, canonical: 1, tag_caption: "Ohio", canonical_caption: "" }, { id: 60, canonical: 0, tag_caption: "OH", canonical_caption: "Ohio" }, { id: 61, canonical: 1, tag_caption: "Oklahoma", canonical_caption: "" }, { id: 62, canonical: 0, tag_caption: "OK", canonical_caption: "Oklahoma" }, { id: 63, canonical: 1, tag_caption: "Oregon", canonical_caption: "" }, { id: 64, canonical: 0, tag_caption: "OR", canonical_caption: "Oregon" }, { id: 65, canonical: 1, tag_caption: "Maryland", canonical_caption: "" }, { id: 66, canonical: 0, tag_caption: "MD", canonical_caption: "Maryland" }, { id: 67, canonical: 1, tag_caption: "Massachusetts", canonical_caption: "" }, { id: 68, canonical: 0, tag_caption: "MA", canonical_caption: "Massachusetts" }, { id: 69, canonical: 1, tag_caption: "Michigan", canonical_caption: "" }, { id: 70, canonical: 0, tag_caption: "MI", canonical_caption: "Michigan" }, { id: 71, canonical: 1, tag_caption: "Minnesota", canonical_caption: "" }, { id: 72, canonical: 0, tag_caption: "MN", canonical_caption: "Minnesota" }, { id: 73, canonical: 1, tag_caption: "Mississippi", canonical_caption: "" }, { id: 74, canonical: 0, tag_caption: "MS", canonical_caption: "Mississippi" }, { id: 75, canonical: 1, tag_caption: "Missouri", canonical_caption: "" }, { id: 76, canonical: 0, tag_caption: "MO", canonical_caption: "Missouri" }, { id: 77, canonical: 1, tag_caption: "Pennsylvania", canonical_caption: "" }, { id: 78, canonical: 0, tag_caption: "PA", canonical_caption: "Pennsylvania" }, { id: 79, canonical: 1, tag_caption: "Rhode Island", canonical_caption: "" }, { id: 80, canonical: 0, tag_caption: "RI", canonical_caption: "Rhode Island" }, { id: 81, canonical: 1, tag_caption: "South Carolina", canonical_caption: "" }, { id: 82, canonical: 0, tag_caption: "SC", canonical_caption: "South Carolina" }, { id: 83, canonical: 1, tag_caption: "South Dakota", canonical_caption: "" }, { id: 84, canonical: 0, tag_caption: "SD", canonical_caption: "South Dakota" }, { id: 85, canonical: 1, tag_caption: "Tennessee", canonical_caption: "" }, { id: 86, canonical: 0, tag_caption: "TN", canonical_caption: "Tennessee" }, { id: 87, canonical: 1, tag_caption: "Texas", canonical_caption: "" }, { id: 88, canonical: 0, tag_caption: "TX", canonical_caption: "Texas" }, { id: 89, canonical: 1, tag_caption: "Utah", canonical_caption: "" }, { id: 90, canonical: 0, tag_caption: "UT", canonical_caption: "Utah" }, { id: 91, canonical: 1, tag_caption: "Vermont", canonical_caption: "" }, { id: 92, canonical: 0, tag_caption: "VT", canonical_caption: "Vermont" }, { id: 93, canonical: 1, tag_caption: "Virginia", canonical_caption: "" }, { id: 94, canonical: 0, tag_caption: "VA", canonical_caption: "Virginia" }, { id: 95, canonical: 1, tag_caption: "Washington", canonical_caption: "" }, { id: 96, canonical: 0, tag_caption: "WA", canonical_caption: "Washington" }, { id: 97, canonical: 1, tag_caption: "West Virginia", canonical_caption: "" }, { id: 98, canonical: 0, tag_caption: "WV", canonical_caption: "West Virginia" }, { id: 99, canonical: 1, tag_caption: "Wisconsin", canonical_caption: "" }, { id: 100, canonical: 0, tag_caption: "WI", canonical_caption: "Wisconsin" }, { id: 101, canonical: 1, tag_caption: "Wyoming", canonical_caption: "" }, { id: 102, canonical: 0, tag_caption: "WY", canonical_caption: "Wyoming" } ]; for (var i = 0; i < data.length; i++) { var o = data[i]; if (o.canonical_caption) { o.tag_caption = o.tag_caption + " (" + o.canonical_caption + ")"; } else { canonical_forms[o.tag_caption] = o; } } cb.setSuggestions (data, 'tag_caption'); } var chip_values = [ { data: { id: 93, canonical: 1, tag_caption: "Virginia", canonical_caption: "" }, caption: "Virginia" }, { data: { id: 51, canonical: 1, tag_caption: "New Mexico", canonical_caption: "" }, caption: "New Mexico" }, { data: { id: 55, canonical: 1, tag_caption: "North Carolina", canonical_caption: "" }, caption: "North Carolina"} ]; var cb = new diesel.ctl.chipbox (); cb.set ({height: 120, width: 400}); cb.addListener ("newValueEntered", on_cb_newValueEntered); cb.addListener ("valueSelected", on_cb_valueSelected); console.log ("loading cb suggestions..."); load_cb_suggestions (); // Document is the application root var doc = this.getRoot (); // Add button to document at fixed coordinates doc.add (cb, { left: 50, top: 50 }); var b = new qx.ui.form.Button ("load chips"); b.addListener ('execute', function () { cb.setChips (chip_values); }); doc.add (b, { left: 50, top: 180 }); |
Great AutoVirtualComboBox.
I have discovered a small bug on line 152 within the AutoVirtualComboBox class
if e.getData() is null then trim() will fail