Cleans up DOM elements manually added by Select2 and not tracked by
React
This commit is contained in:
@@ -57,7 +57,7 @@ define([
|
|||||||
},
|
},
|
||||||
destroySelect2: function () {
|
destroySelect2: function () {
|
||||||
if (this.isSelect2Initialized()) {
|
if (this.isSelect2Initialized()) {
|
||||||
jQuery(`#${this.refs.select.id}`).select2('destroy');
|
jQuery(`#${this.refs.select.id}`).select2('destroy').find('option:not(.default)').remove();
|
||||||
this.state.select2 = false;
|
this.state.select2 = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -206,7 +206,7 @@ define([
|
|||||||
// For single selects only, in order for the placeholder value to appear,
|
// For single selects only, in order for the placeholder value to appear,
|
||||||
// we must have a blank <option> as the first option in the <select> control.
|
// we must have a blank <option> as the first option in the <select> control.
|
||||||
if (this.allowMultipleValues()) return undefined;
|
if (this.allowMultipleValues()) return undefined;
|
||||||
if (this.props.field.placeholder) return (<option />);
|
if (this.props.field.placeholder) return (<option className="default" />);
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
@@ -219,6 +219,7 @@ define([
|
|||||||
return (
|
return (
|
||||||
<option
|
<option
|
||||||
key={`option-${index}`}
|
key={`option-${index}`}
|
||||||
|
className="default"
|
||||||
value={value}
|
value={value}
|
||||||
title={searchLabel}
|
title={searchLabel}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user