From ae9f373cff0b3b9a1516630c49ff502d7c9332bd Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 1 Feb 2018 17:53:16 -0500 Subject: [PATCH] Removes state and updates method to test if Select2 is initialized --- assets/js/src/form/fields/selection.jsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/assets/js/src/form/fields/selection.jsx b/assets/js/src/form/fields/selection.jsx index ff24c87264..656ac4d3c9 100644 --- a/assets/js/src/form/fields/selection.jsx +++ b/assets/js/src/form/fields/selection.jsx @@ -10,16 +10,11 @@ define([ jQuery ) => { const Selection = React.createClass({ - getInitialState: function () { - return { - select2: false, - }; - }, allowMultipleValues: function () { return (this.props.field.multiple === true); }, isSelect2Initialized: function () { - return (this.state.select2 === true); + return (jQuery(`#${this.refs.select.id}`).hasClass('select2-hidden-accessible') === true) }, componentDidMount: function () { if (this.allowMultipleValues() || this.props.field.forceSelect2) { @@ -58,7 +53,6 @@ define([ destroySelect2: function () { if (this.isSelect2Initialized()) { jQuery(`#${this.refs.select.id}`).select2('destroy').find('option:not(.default)').remove(); - this.state.select2 = false; } }, setupSelect2: function () { @@ -128,8 +122,6 @@ define([ }); select2.on('change', this.handleChange); - - this.state.select2 = true; }, getSelectedValues: function () { if (this.props.field.selected !== undefined) {