From 1801b24389baa8e3f7298ff2c41e2512b19c1290 Mon Sep 17 00:00:00 2001 From: Einav Weiss Keidar Date: Mon, 13 Aug 2018 16:19:46 +0300 Subject: react 16 upgrade Issue-ID: SDC-1762 Change-Id: I7701f12fc63bb09f8c985c7c893b984701dcbfab Signed-off-by: Einav Keidar --- .../input/dualListbox/DualListboxView.jsx | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'openecomp-ui/src/nfvo-components/input/dualListbox') diff --git a/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx b/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx index f36d999249..21f09e6613 100644 --- a/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx +++ b/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx @@ -16,9 +16,16 @@ import React from 'react'; import PropTypes from 'prop-types'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; class DualListboxView extends React.Component { + constructor(props) { + super(props); + this.availableListRef = React.createRef(); + this.availableListFilterRef = React.createRef(); + this.selectedValuesListFilterRef = React.createRef(); + this.selectedValuesRef = React.createRef(); + } static propTypes = { availableList: PropTypes.arrayOf( PropTypes.shape({ @@ -77,13 +84,13 @@ class DualListboxView extends React.Component { unselectedList, { value: availableListFilter, - ref: 'availableListFilter', + ref: this.availableListFilterRef, disabled: isReadOnlyMode, onChange: value => this.setState({ availableListFilter: value }) }, { - ref: 'availableValues', + ref: this.availableListRef, disabled: isReadOnlyMode, testId: 'available' } @@ -94,13 +101,13 @@ class DualListboxView extends React.Component { selectedList, { value: selectedValuesListFilter, - ref: 'selectedValuesListFilter', + ref: this.selectedValuesListFilterRef, disabled: isReadOnlyMode, onChange: value => this.setState({ selectedValuesListFilter: value }) }, { - ref: 'selectedValues', + ref: this.selectedValuesRef, disabled: isReadOnlyMode, testId: 'selected' } @@ -236,6 +243,12 @@ class DualListboxView extends React.Component { removeAllFromSelectedList() { this.props.onChange([]); } + + // fix for auto-selection of first value in the list on the first render + componentDidMount() { + this.availableListRef.current.input.value = ''; + this.selectedValuesRef.current.input.value = ''; + } } export default DualListboxView; -- cgit 1.2.3-korg