Skip to content

direction="vertical" on <Sortable> not working and <Sortable> in overflow:scroll buggy? #55

Description

@myleschuahiock

Hi Jason,

The direction="vertical" on my code doesn't seem to work in my code. However containment: true works, the only bug is when the parent container has a overflow: scroll.

Here's a simplified test case of how I'm implementing my code and also an "almost" carbon-copy code of your "vertical" demo.

App.js

import React from 'react';
import Sortable from 'react-anything-sortable';
import { sortable } from 'react-anything-sortable';

@sortable
class WidgetListItem extends React.Component {
    render() {
        return (
            <div {...this.props}>
                {this.props.children}
            </div>
        )
    }
}

export default class WidgetList extends React.Component {
    constructor() {
        super();
        this.state = {};
    }

    handleSort(data) {
        this.setState({
            result: data.join(' ')
        });
    }

    toggleCheckbox(evt) {
        console.log(evt)
    }

    render() {
        let items = [1,2,3,4,5,6,7,8,9,10]
        // TODO: move widget creation to its own component <WidgetItem/>
        const widgetItems = items.map(i => {
            return (
                <WidgetListItem className="vertical" sortData={i} key={i}>
                    Widget {i}
                </WidgetListItem>
            )
        })
        return <div>
                <h1>React Sortable Test</h1>
                <Sortable onSort={::this.handleSort} containment="true" className="vertical-container" direction="vertical">
                    {widgetItems}
                </Sortable>
        </div>
    }
}
/* pre-built style */
.ui-sortable {
  display: block;
  position: relative;
  overflow: visible;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.ui-sortable:before,
.ui-sortable:after{
  content: " ";
  display: table;
}

.ui-sortable:after{
  clear: both;
}

.ui-sortable .ui-sortable-item {
  float: left;
  cursor: move;
}

.ui-sortable .ui-sortable-item.ui-sortable-dragging {
  position: absolute;
  z-index: 1688;
}

.ui-sortable .ui-sortable-placeholder {
  display: none;
}

.ui-sortable .ui-sortable-placeholder.visible {
  display: block;
  z-index: -1;
}

/*custom*/
.vertical-container {
  width: 200px;
  padding: 10px;
  border: 1px #ccc solid;


  height:150px;
  overflow: scroll;
}

.vertical.ui-sortable-item {
  float: none;
  display: block;
  width: 100%;
  padding: 10px 5px;
  margin-bottom: 10px;
  border: 1px #eee solid;
}

It's weird that the direction="vertical" works for on your GitHub demo, but not on mine (maybe only doesn't work for me?)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions