Skip to content

Commit

Permalink
properly destroy dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
lenadax committed Feb 24, 2025
1 parent 2f41222 commit ee23232
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
9 changes: 8 additions & 1 deletion js/src/default/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export class AutocompleteSuggestion {
this.selected = true;
this.widget.select_suggestion(this.id, this.value);
}

destroy() {
this.elem.off('mousedown', this.select);
}
}

export class AutocompleteWidget {
Expand Down Expand Up @@ -126,11 +130,14 @@ export class AutocompleteWidget {

destroy() {
clearTimeout(this.timeout);
this.dd_elem.remove();
for (let suggestion of this.suggestions) {
suggestion.destroy();
}
this.input_elem
.off('focusout', this.hide_dropdown)
.off('focus input', this.on_input)
.off('keydown', this.on_keydown);
this.dd_elem.off().empty().remove();
}

parse_source() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var yafowil_autocomplete = (function (exports, $) {
this.selected = true;
this.widget.select_suggestion(this.id, this.value);
}
destroy() {
this.elem.off('mousedown', this.select);
}
}
class AutocompleteWidget$1 {
static initialize(context) {
Expand Down Expand Up @@ -108,11 +111,14 @@ var yafowil_autocomplete = (function (exports, $) {
}
destroy() {
clearTimeout(this.timeout);
this.dd_elem.remove();
for (let suggestion of this.suggestions) {
suggestion.destroy();
}
this.input_elem
.off('focusout', this.hide_dropdown)
.off('focus input', this.on_input)
.off('keydown', this.on_keydown);
this.dd_elem.off().empty().remove();
}
parse_source() {
const source = this.input_elem.data('source');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/yafowil/widget/autocomplete/resources/default/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var yafowil_autocomplete = (function (exports, $) {
this.selected = true;
this.widget.select_suggestion(this.id, this.value);
}
destroy() {
this.elem.off('mousedown', this.select);
}
}
class AutocompleteWidget {
static initialize(context) {
Expand Down Expand Up @@ -108,11 +111,14 @@ var yafowil_autocomplete = (function (exports, $) {
}
destroy() {
clearTimeout(this.timeout);
this.dd_elem.remove();
for (let suggestion of this.suggestions) {
suggestion.destroy();
}
this.input_elem
.off('focusout', this.hide_dropdown)
.off('focus input', this.on_input)
.off('keydown', this.on_keydown);
this.dd_elem.off().empty().remove();
}
parse_source() {
const source = this.input_elem.data('source');
Expand Down
Loading

0 comments on commit ee23232

Please sign in to comment.