From 3092a96a684478276c5c396e7909e5ef457a7be1 Mon Sep 17 00:00:00 2001 From: grainsoft Date: Wed, 18 Feb 2026 03:13:44 +0200 Subject: [PATCH] updates --- src/utils/dom.js | 2 +- src/widgets/autocomplete/Autocomplete.js | 54 +++++------------------- 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/utils/dom.js b/src/utils/dom.js index 92cf404..111914e 100644 --- a/src/utils/dom.js +++ b/src/utils/dom.js @@ -552,7 +552,7 @@ /** * Get Widget Data Value */ - nval() { + key() { return this[ Ut.WidgetUID ]?.getValue(); }, diff --git a/src/widgets/autocomplete/Autocomplete.js b/src/widgets/autocomplete/Autocomplete.js index 32e7380..972e5b7 100644 --- a/src/widgets/autocomplete/Autocomplete.js +++ b/src/widgets/autocomplete/Autocomplete.js @@ -7,9 +7,6 @@ import { Cancelable } from '../cancelable' export class Autocomplete { - /** - * Autocomplete, Constructor - */ constructor(target, data, opts) { this.target = target; @@ -43,15 +40,12 @@ export class Autocomplete { } new Cancelable(this.target); - + this.renderContainer(); this.setEvents(); } - /** - * Autocomplete, Render Container - */ renderContainer() { this.ui = { @@ -61,9 +55,6 @@ export class Autocomplete { this.ui.wrapper.style.maxHeight = (this.opts.maxOptions * this.opts.optionHeight) + 'px'; } - /** - * Autocomplete, Set Events - */ setEvents() { // Input Event Handler @@ -79,15 +70,12 @@ export class Autocomplete { this.ui.wrapper.dxOn('click', '.ac-option', (e, t) => this.clickOptionHandler(e, t)); // Click outside - document.body.dxOn('click.autocomplete', e => e.target != this.target && this.clear()); + document.body.dxOn('click.autocomplete', e => e.target != this.target && this.release()); } - /** - * Autocomplete, processData - */ processData(val) { - this.clear(); + this.release(); let found = true; let matchId = ''; @@ -143,9 +131,6 @@ export class Autocomplete { } } - /** - * Autocomplete, Input Handler - */ inputHandler(_, t) { //e.stopPropagation(); @@ -172,9 +157,6 @@ export class Autocomplete { } } - /** - * Autocomplete, Keydown Event Handler - */ keydownHandler(e, t) { if (!this.count) { @@ -220,21 +202,15 @@ export class Autocomplete { } } - /** - * Autocomplete, Click Option Handler - */ clickOptionHandler(e, t) { e.stopPropagation(); this.restoreValue(t.dataset.id); } - /** - * Autocomplete, Update Val - */ restoreValue(id) { if (id == this.value) { - this.clear(); + this.release(); return; } @@ -245,16 +221,13 @@ export class Autocomplete { Ut.trigger(this.opts.onChange, this); this.target.dxTrigger('changed'); - this.clear(); + this.release(); } getValue() { return this.value; } - /** - * Autocomplete, Set Active Option - */ setActiveOption() { this.selected = this.ui.wrapper.children[this.index]; @@ -278,20 +251,18 @@ export class Autocomplete { } } - /** - * Autocomplete Update Options - */ updateOptions(data) { - this.clear(); this.data = data; } - /** - * Autocomplete Clear Options - */ clear() { - + this.value = ''; + this.release(); + } + + release() { + this.selected = null; this.count = 0; this.index = -1; @@ -302,9 +273,6 @@ export class Autocomplete { this.ui.wrapper.dxHtml(''); } - /** - * Autocomplete, Destroy - */ destroy() { this.ui.wrapper.remove();