From 378f053b186f23f6b28bcdbddb3042770100d97f Mon Sep 17 00:00:00 2001 From: Juan Date: Sat, 17 Mar 2018 13:17:48 +0100 Subject: [PATCH] vnAutocomplete behavior modified to act like ms access combo --- .../components/autocomplete/autocomplete.html | 10 ++++----- .../src/components/drop-down/drop-down.js | 21 ++++++++++++------- client/core/src/components/popover/popover.js | 3 --- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/client/core/src/components/autocomplete/autocomplete.html b/client/core/src/components/autocomplete/autocomplete.html index 0ee10c5ae..4d04f884f 100755 --- a/client/core/src/components/autocomplete/autocomplete.html +++ b/client/core/src/components/autocomplete/autocomplete.html @@ -16,8 +16,8 @@ - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/client/core/src/components/drop-down/drop-down.js b/client/core/src/components/drop-down/drop-down.js index 482297618..07a856273 100755 --- a/client/core/src/components/drop-down/drop-down.js +++ b/client/core/src/components/drop-down/drop-down.js @@ -45,6 +45,9 @@ export default class DropDown extends Component { this._search = value; this.$.model.clear(); + if (value != null) + this._activeOption = 0; + this.$timeout.cancel(this.searchTimeout); this.searchTimeout = this.$timeout(() => { this.refreshModel(); @@ -86,8 +89,8 @@ export default class DropDown extends Component { * @param {String} search The initial search term or %null */ show(search) { - this.search = search; this._activeOption = -1; + this.search = search; this.buildList(); this.$.popover.parent = this.parent; this.$.popover.show(); @@ -101,7 +104,7 @@ export default class DropDown extends Component { } /** - * Activates a option and scrolls the drop-down to that option. + * Activates an option and scrolls the drop-down to that option. * * @param {Number} option The option index */ @@ -122,7 +125,7 @@ export default class DropDown extends Component { } /** - * Activates a option. + * Activates an option. * * @param {Number} option The option index */ @@ -146,10 +149,11 @@ export default class DropDown extends Component { * @param {Number} option The option index */ selectOption(option) { - if (option != -1) { - let data = this.$.model.data; - let item = data ? data[option] : null; - let value = item ? item[this.valueField] : null; + let data = this.$.model.data; + let item = option != -1 && data ? data[option] : null; + + if (item) { + let value = item[this.valueField]; if (this.multiple) { if (!Array.isArray(this.selection)) { @@ -252,6 +256,9 @@ export default class DropDown extends Component { let nOpts = data ? data.length - 1 : 0; switch (event.keyCode) { + case 9: // Tab + this.selectOption(option); + return; case 13: // Enter this.selectOption(option); break; diff --git a/client/core/src/components/popover/popover.js b/client/core/src/components/popover/popover.js index 4e2326c77..1756bd58f 100644 --- a/client/core/src/components/popover/popover.js +++ b/client/core/src/components/popover/popover.js @@ -96,9 +96,6 @@ export default class Popover extends Component { if (this.deregisterCallback) this.deregisterCallback(); - if (this.parent) - this.parent.focus(); - if (this.onClose) this.onClose(); }