Skip to content

Conversation

ermyril
Copy link
Contributor

@ermyril ermyril commented Dec 25, 2019

Versions after 2.0.2 was throwing Cannot read property 'length' of undefined for a check of length of evt.oldIndicies, right after the first drag&drop operation, so future interactions were impossible, that simple additional check helped me with that. Most likely I've introduced a dirty hack though :D

found #111 issue, and as stated there, instantiating MultiDrag and connecting it manually with Sortable via

Sortable.mount(new MultiDrag());

helps, but it seems more like a workaround and not an expected behaviour.

By the way, I can confirm that react-sortablejs works with AntDesign and its form elements.

@waynevanson
Copy link
Collaborator

waynevanson commented Dec 25, 2019

@ermyril Nice one!

Can you post a snippet of integration with AntDesign? Someone tried a few weeks ago and not even I could get it to work.

A reminder to self that I need to update the type definitions.

@waynevanson waynevanson self-requested a review December 25, 2019 23:20
@waynevanson waynevanson merged commit aa96307 into SortableJS:master Dec 25, 2019
@ermyril
Copy link
Contributor Author

ermyril commented Dec 27, 2019

@waynevanson, sure, here is a simple example. I've used it with form elements (did not tested it with ant's HOC for forms, but I think it will work), in my project I have wrapped my fields with ant layout components (Rows), and I assume that it will work fine with any component from Data Entry category. Here is a code example:

    wrapField(field, key) {
        const reactKey = this.state.content[key].key;
        return (
            <Row key={reactKey}>
                <Col span={20}>
                    {field}
                </Col>
                <Col span={4}>
                    <Icon type="menu" className="handle" />
                </Col>
            </Row>
        );
    }
    <ReactSortable
        list={this.state.content}
        setList={ newState => {
               return this.setState(
                    { content: newState }
                   )
                }
            }
      handle=".handle"
    >
        {fields}
    </ReactSortable>

Also I've checked data display elements like <List /> and <Table />, and did not succeeded in it, the main reason is that draggable elements should be direct childrens of <ReactSortable /> and antd wraps table rows and list elements in wrappers, so we will get just one draggable item (a whole <Table /> or <List /> itself), maybe it's somehow possible but definitely needs a deep look into SortableJS api to get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants