Skip to content

Commit

Permalink
Fixed #2250 - PickList not working webpack 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 6, 2021
1 parent 2f85957 commit 4a676c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/components/picklist/PickList.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types';
import { DomHandler, classNames } from '../utils/Utils';
import { DomHandler, classNames, ObjectUtils } from '../utils/Utils';
import { PickListSubList } from './PickListSubList';
import { PickListControls } from './PickListControls';
import { PickListTransferControls } from './PickListTransferControls';
Expand Down Expand Up @@ -186,7 +186,9 @@ export class PickList extends Component {

scrollInView(listContainer, direction = 1) {
let selectedItems = listContainer.getElementsByClassName('p-highlight');
DomHandler.scrollInView(listContainer, (direction === -1 ? selectedItems[0] : selectedItems[selectedItems.length - 1]));
if (ObjectUtils.isNotEmpty(selectedItems)) {
DomHandler.scrollInView(listContainer, (direction === -1 ? selectedItems[0] : selectedItems[selectedItems.length - 1]));
}
}

onSelectionChange(e, stateKey, callback) {
Expand All @@ -197,10 +199,10 @@ export class PickList extends Component {
this.setState({ [stateKey]: e.value });
}

if (this.state.sourceSelection && this.state.sourceSelection.length && stateKey === 'targetSelection') {
if (ObjectUtils.isNotEmpty(this.state.sourceSelection) && stateKey === 'targetSelection') {
this.setState({ sourceSelection: [] })
}
else if (this.state.targetSelection && this.state.targetSelection.length && stateKey === 'sourceSelection') {
else if (ObjectUtils.isNotEmpty(this.state.targetSelection) && stateKey === 'sourceSelection') {
this.setState({ targetSelection: [] })
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/components/picklist/PickListTransferControls.js
Expand Up @@ -16,7 +16,7 @@ export class PickListTransferControls extends Component {
moveRight(event) {
let selection = this.props.sourceSelection;

if (selection && selection.length) {
if (ObjectUtils.isNotEmpty(selection)) {
let targetList = [...this.props.target];
let sourceList = [...this.props.source];

Expand Down Expand Up @@ -58,7 +58,7 @@ export class PickListTransferControls extends Component {
moveLeft(event) {
let selection = this.props.targetSelection;

if (selection && selection.length) {
if (ObjectUtils.isNotEmpty(selection)) {
let targetList = [...this.props.target];
let sourceList = [...this.props.source];

Expand Down Expand Up @@ -100,10 +100,10 @@ export class PickListTransferControls extends Component {


render() {
let moveRightDisabled = !this.props.sourceSelection.length;
let moveLeftDisabled = !this.props.targetSelection.length;
let moveAllRightDisabled = !this.props.source.length;
let moveAllLeftDisabled = !this.props.target.length;
let moveRightDisabled = ObjectUtils.isEmpty(this.props.sourceSelection);
let moveLeftDisabled = ObjectUtils.isEmpty(this.props.targetSelection);
let moveAllRightDisabled = ObjectUtils.isEmpty(this.props.source);
let moveAllLeftDisabled = ObjectUtils.isEmpty(this.props.target);

let className = classNames('p-picklist-buttons p-picklist-transfer-buttons', this.props.className);

Expand Down

0 comments on commit 4a676c5

Please sign in to comment.