Skip to content

Commit

Permalink
Fixed #1494 - Remove responsive property from OrderList
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Aug 11, 2020
1 parent 630ff58 commit b52c7e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/components/orderlist/OrderList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ interface OrderListProps {
style?: object;
className?: string;
listStyle?: object;
responsive?: boolean;
dragdrop?: boolean;
tabIndex?: string;
onChange?(e: {originalEvent: Event, value: any}): void;
Expand Down
36 changes: 16 additions & 20 deletions src/components/orderlist/OrderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class OrderList extends Component {
style: null,
className: null,
listStyle: null,
responsive: false,
dragdrop: false,
tabIndex: '0',
onChange: null,
Expand All @@ -29,7 +28,6 @@ export class OrderList extends Component {
style: PropTypes.object,
className: PropTypes.string,
listStyle: PropTypes.object,
responsive: PropTypes.bool,
dragdrop: PropTypes.bool,
tabIndex: PropTypes.string,
onChange: PropTypes.func,
Expand All @@ -52,7 +50,7 @@ export class OrderList extends Component {
let index = ObjectUtils.findIndexInList(event.value, this.state.selection);
let selected = (index !== -1);
let selection;

if (selected) {
if (metaKey)
selection = this.state.selection.filter((val, i) => i !== index);
Expand All @@ -65,34 +63,34 @@ export class OrderList extends Component {
else
selection = [event.value];
}

this.setState({selection: selection});
}

onItemKeyDown(event) {
let listItem = event.originalEvent.currentTarget;

switch(event.originalEvent.which) {
//down
case 40:
var nextItem = this.findNextItem(listItem);
if (nextItem) {
nextItem.focus();
}

event.originalEvent.preventDefault();
break;

//up
case 38:
var prevItem = this.findPrevItem(listItem);
if (prevItem) {
prevItem.focus();
}

event.originalEvent.preventDefault();
break;

//enter
case 13:
this.onItemClick(event);
Expand All @@ -115,12 +113,12 @@ export class OrderList extends Component {

findPrevItem(item) {
let prevItem = item.previousElementSibling;

if (prevItem)
return !DomHandler.hasClass(prevItem, 'p-orderlist-item') ? this.findPrevItem(prevItem) : prevItem;
else
return null;
}
}

onReorder(event) {
if (this.props.onChange) {
Expand Down Expand Up @@ -148,38 +146,36 @@ export class OrderList extends Component {
case 'up':
DomHandler.scrollInView(this.subList.listElement, listItems[0]);
break;

case 'top':
this.subList.listElement.scrollTop = 0;
break;

case 'down':
DomHandler.scrollInView(this.subList.listElement, listItems[listItems.length - 1]);
break;

case 'bottom':
this.subList.listElement.scrollTop = this.subList.listElement.scrollHeight;
break;

default:
break;
}
}
}

render() {
let className = classNames('p-orderlist p-component', this.props.className, {
'p-orderlist-responsive': this.props.responsive
});
let className = classNames('p-orderlist p-component', this.props.className);

return (
<div ref={(el) => this.element = el} id={this.props.id} className={className} style={this.props.style}>
<OrderListControls value={this.props.value} selection={this.state.selection} onReorder={this.onReorder} />
<OrderListSubList ref={(el) => this.subList = el} value={this.props.value} selection={this.state.selection} onItemClick={this.onItemClick} onItemKeyDown={this.onItemKeyDown}
<OrderListSubList ref={(el) => this.subList = el} value={this.props.value} selection={this.state.selection} onItemClick={this.onItemClick} onItemKeyDown={this.onItemKeyDown}
itemTemplate={this.props.itemTemplate} header={this.props.header} listStyle={this.props.listStyle}
dragdrop={this.props.dragdrop} onDragStart={this.onDragStart} onDragEnter={this.onDragEnter} onDragEnd={this.onDragEnd} onDragLeave={this.onDragEnter} onDrop={this.onDrop}
onChange={this.props.onChange} tabIndex={this.props.tabIndex} />
</div>
);
}
}
}

0 comments on commit b52c7e6

Please sign in to comment.