mirror of
https://github.com/discourse/discourse.git
synced 2025-04-27 17:04:29 +08:00
FIX: ensures popper's autocomplete instance is destroyed (#12476)
This commit is contained in:
parent
129aeb8c2f
commit
4fb2d397a4
@ -15,6 +15,7 @@ import { iconHTML } from "discourse-common/lib/icon-library";
|
|||||||
export const SKIP = "skip";
|
export const SKIP = "skip";
|
||||||
export const CANCELLED_STATUS = "__CANCELLED";
|
export const CANCELLED_STATUS = "__CANCELLED";
|
||||||
const allowedLettersRegex = /[\s\t\[\{\(\/]/;
|
const allowedLettersRegex = /[\s\t\[\{\(\/]/;
|
||||||
|
let _autoCompletePopper;
|
||||||
|
|
||||||
const keys = {
|
const keys = {
|
||||||
backSpace: 8,
|
backSpace: 8,
|
||||||
@ -112,6 +113,8 @@ export default function (options) {
|
|||||||
let inputSelectedItems = [];
|
let inputSelectedItems = [];
|
||||||
|
|
||||||
function closeAutocomplete() {
|
function closeAutocomplete() {
|
||||||
|
_autoCompletePopper && _autoCompletePopper.destroy();
|
||||||
|
|
||||||
if (div) {
|
if (div) {
|
||||||
div.hide().remove();
|
div.hide().remove();
|
||||||
}
|
}
|
||||||
@ -119,6 +122,7 @@ export default function (options) {
|
|||||||
completeStart = null;
|
completeStart = null;
|
||||||
autocompleteOptions = null;
|
autocompleteOptions = null;
|
||||||
prevTerm = null;
|
prevTerm = null;
|
||||||
|
_autoCompletePopper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInputSelectedItem(item, triggerChangeCallback) {
|
function addInputSelectedItem(item, triggerChangeCallback) {
|
||||||
@ -315,7 +319,8 @@ export default function (options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isInput || options.treatAsTextarea) {
|
if (isInput || options.treatAsTextarea) {
|
||||||
return createPopper(me[0], div[0], {
|
_autoCompletePopper && _autoCompletePopper.destroy();
|
||||||
|
_autoCompletePopper = createPopper(me[0], div[0], {
|
||||||
placement: "bottom-start",
|
placement: "bottom-start",
|
||||||
strategy: "fixed",
|
strategy: "fixed",
|
||||||
modifiers: [
|
modifiers: [
|
||||||
@ -327,6 +332,7 @@ export default function (options) {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
return _autoCompletePopper;
|
||||||
}
|
}
|
||||||
|
|
||||||
let vOffset = 0;
|
let vOffset = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user