Giter VIP home page Giter VIP logo

react-beautiful-dnd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-beautiful-dnd's Issues

Custom keyboard bindings

Add the ability to provide your own key bindings.

Still unsure if this is the right thing to do given that it is really easy to do the wrong thing by the browser - but we will investigate it!

Server rendering the component.

Feature Request

Are there any plans to support serverside rendering of this library? Currently when rendered on the server an error is printed out.

Author on parental leave - but others will be moving forward

Hi everyone,

Very soon I will be going on leave for six weeks to help look after our soon to be born second child. Exciting times! While I am away a number of my colleges from Atlassian will be continuing to move this library forward. I will still be around occasionally but they will be the primary contributors for that time.

Cheers

Optimised placeholder placement

Right now when you hover over a foreign list the original draggable placeholder remains. This is to avoid the list collapsing. However, I think it would be better to enable the Droppable placeholder for the home list to avoid collapsing but to avoid having a gap in the list.

Full placeholder rules:

  • when dragging over a home list - use the Draggable placeholder
  • when dragging over no list - use the Draggable placeholder
  • when dragging over a foreign list - use the Droppable placeholder in both the home and foreign Droppable.

Force press clicking messes with Dragging on Safari

Bug or feature request?

Bug

Expected behaviour

When releasing her finger from the trackpad, the card should remain to the list; it should not remain sticked to the cursor

Actual behaviour

See video https://www.youtube.com/watch?v=-gWQ9hkjUj8

The radar effect happens when the user releases the card.
Even though the user releases the card, she can still move things around.

This bug manifests itself on all the example pages.

Steps to reproduce

See https://www.youtube.com/watch?v=-gWQ9hkjUj8

You probably need a magic trackpad instead of a mouse.
Isssue manifests itself in the recent Mac OS, at the very least.

I suspect, but I haven’t time to dig in, that it might be related to “force touch”.

Demo

Here is a video with pointer events recorded, to help you:

https://www.youtube.com/watch?v=-gWQ9hkjUj8

Multi drag support

Support the dragging of multiple Draggables. There are still a lot of open questions about this one.

  • Currently the library has no concept of selecting a Draggable. What would this look like to support 'select' - is this handled by the library - or is it a pattern?
  • What is the expected visual experience for a multi drag
  • What would the api for onDragStart and onDragEnd look like?

Improve the performance of dimension capturing

Currently there is a DIMENSION_COLLECTING phase before a drag where we request the dimensions for all of the Droppable and Draggable components. This is quite expensive as it calls .getBoundingClientRect and window.getComputedStyle on all the nodes. We need to think more about how we could improve the performance of this. Some options off the top of my head:

  • (simplier) find a cheaper way of getting the margin values off an element. I had a look and I could not find one, but it is worth further investigation
  • (simplier) allow drag movement before all the dimensions are requested (this would not help with keyboard dragging)
  • (more complex) only request a batch of dimensions (such as those in the current viewport) and request more dimensions as needed. This is tricky because it may jank the scroll, and also will change how we calculate the index of the current item.

Expose flowtypes

There are some flow types in the system that would be worth exporting. At a minimum flow should know that react-beautiful-dnd contains three exports (DragDropContext, Droppable and Draggable). But it would be good to also expose the types that are documented in README.md so that people using flow can type their code correctly.

I am not sure what the best practice is for this.

My thought is to import all the types I want to export into src/index.js and then export them from there. However, I am not sure what to do from there - should we just copy an index.js.flow into the generated /lib folder - is that enough?

The path we choose should not expose every type in the system. There are some types such as State which are not public API and purely for internal use.

Information about the drop target

Hi @alexreardon, this library looks great - thank you for putting it out! I have a usecase where on drop, I'd like to distinguish between if the item was dropped between two items or on top of an item.

So, I am wondering if you foresee the API supporting that, and/or boundaries within a target (that helps determine intent of drop - like middle 50% is considered dropping on the target)?

Thank you!

Allow for shared scrollable parents

@bobrovnik found a missing piece of functionality in #89: we need to support the use case whether some drag and drop components sit within a larger scroll container (such as at the root level).

The first pass will need to ensure that things work when non-scrollable containers sit inside a shared scrollable parent. This will also include intercating with otherDroppables including:

  • Droppables without a scroll container
  • Droppables with a scroll container
    -``Droppables` without an immiediate scroll container but with a shared scroll container

The second pass will need to ensure that the above works with the addition of:

  • a Droppable inside a scroll container inside a shared parent scroll container

Fun times

2,000 ⭐️!

Thank you to everyone for your show of support for react-beautiful-dnd. Obtaining 2000 ⭐️ in only a bit over a week is super encouraging. We are excited to see the ideas that this library brings resonated with so many.

rainbow-jake

Dynamically change hooks after first render

I was playing with this library on a toy side-project, and I noticed I cannot dynamically change hooks, especially after the first render.

The gist of the code I had is as follows:

import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";

import { compose, withState } from "recompose";

// fake data generator
const getItems = count =>
    Array.from({ length: count }, (v, k) => k).map(k => ({
        id: `item-${k}`,
        content: `item ${k}`,
        type: generateType(k)
    }));

// ...

const onDragEnd = setCards => result => {
    // dropped outside the list
    if (!result.destination) {
        return;
    }

    setCards(prevCards => {
        const nextCards = reorder(
            prevCards,
            result.source.index,
            result.destination.index
        );
        return nextCards;
    });
};

const Board = props => {
    const { cards, setCards } = props;

    return (
        // NOTE: unable to replace onDragEnd after first render
        <DragDropContext onDragEnd={onDragEnd(setCards)}>
            <Droppable droppableId="droppable">
                {generateBoard(cards)}
            </Droppable>
        </DragDropContext>
    );
};

const cardsState = withState("cards", "setCards", getItems(10));

export default compose(cardsState)(Board);

Even though the drag and drop (which is awesome by the way) appears to work fine, after the first render, the generated function from onDragEnd(setCards) is not replaced within DragDropContext.

This is likely to do with the fact there is no componentWillReceiveProps() (or similar) at

export default class DragDropContext extends Component {
/* eslint-disable react/sort-comp */
props: Props
store: Store
// Need to declare childContextTypes without flow
// https://github.com/brigand/babel-plugin-flow-react-proptypes/issues/22
static childContextTypes = {
[storeKey]: PropTypes.shape({
dispatch: PropTypes.func.isRequired,
subscribe: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
}).isRequired,
}
/* eslint-enable */
componentWillMount() {
this.store = createStore(this.props);
}
getChildContext(): Context {
return {
[storeKey]: this.store,
};
}
render() {
return this.props.children;
}
}


Even though the above example uses recompose, one may refactor the above to use redux and friends (e.g. react-redux), whereby the developer can pass dispatch (or a binded dispatch) to onDragEnd(). You cannot really assume dispatch won't change after the first render.

Shortcuts customization

You did an amazing library. But to use it is not very convenient. Let me propose my own version:

When element is't selected:
tab - move focus to next element
shift + tab - move focus to previous element
space - for select element

When element is selected:
tab to move selected element to next position
tab + tab to move selected element to previous position
esc or space - to remove selection from element

It seems to me more convenient and intuitive.

Do you plan to add a customization to shortcuts?

Problem with strict peerDependency

Firstly, thanks for this component, it's great.

Why this component has strict peerDependency react 15.6.1?
Have you real causes for it?
Could it be changed to somthing like >=15.4.0?
We cannot use your component if we have other react version.
We very disappointed about it.

Thanks.

Optimise bundle

Right how the generated source code is fairly simple: just run everything through babel. However, we could use tools like rollup and prepack to optimise the bundle before it is ever consumed.

Programatic cancelling of a drag

Once a drag has started there is no way to cancel it except through user input. There may be a scenario where the application wants to clear any current drag

Disable animation if required

If the users device is struggling then we should disable as much animation as possible.

There are a few different approaches we could purse - either in combination or in isolation. They are:

  1. disabling animation for offscreen movements
  2. disabling animation based on the amount of things moving (disable once a threshold is passed)
  3. disabling animation based on the frame rate (more magic but potentially more flexible)

Dragging big items

Bug or feature request?

(answer here)

Expected behaviour

Actual behaviour

Steps to reproduce

Browser version

Demo

Auto scrolling

Current mitigation: use your trackpack or mouse to scroll while you are dragging. There was actually a lot of work done to make sure scroll is being listened to directly

Currently when dragging with a mouse the window will not automatically scroll. Nor will scroll containers automatically scroll. We could support this behaviour.

A few things to consider:

Scroll containers

  • Currently the library does not do too much with the DOM - it just works. Introducing a feature like this might require an additional export: a scrollable container. Perhaps also even an option for Droppables to support auto scrolling. Should it be opt in or default?
  • Window auto scrolling would be relatively simpler and could probably be turned on by default.

Automatic releasing

Right now when I want to bump I version I just:

  1. create a commit which bumps the package json
  2. tag the commit
  3. push the commit to github
  4. publish on npm

🙃 I know.

I wanted to keep it crazy simple to start and build from there. It would be worth setting up travis to do this for us.

Will react-beautiful-dnd just support for React?

Will react-beautiful-dnd support for other libraries? For example: Vue or angular?

Because the license of React has changed as BSD+Patents, my company is on discussing to change our Front-end library to others.
In addition, Is there any idea of the license issue in Atlassian?

Add mobile / touch support

Currently the library only supports keyboard and mouse dragging. It would useful to add touch support so that it can be used on touch devices (eg phones and tablets)

Cursor type set for Draggable is not respected while dragging

Bug or feature request?

Bug

Expected behaviour

  1. Move the mouse over a draggable. -> Cursor changes to grab.
  2. Start dragging. -> Cursor changes to grabbing.

Actual behaviour

Cursor is changing to grab as expected when mouse is moved over a draggable.
Cursor changes to default when a draggable is being dragged -- as opposed to exepcted grabbing.

Steps to reproduce

Add the following to the object returned by the getItemStyle function in the basic example (https://www.webpackbin.com/bins/-KuZVBLKLMq2RG9M5jkK)

  cursor: isDragging ? '-webkit-grabbing' : '-webkit-grab',
  1. Move the mouse over a draggable. -> Observe that the cursor changes to grab.
  2. Start dragging. -> Observe that the cursor changes to default.

Browser version

Chrome Version 60.0.3112.113 (Official Build) (64-bit)

Demo

Add the following to the object returned by the getItemStyle function in the basic example (https://www.webpackbin.com/bins/-KuZVBLKLMq2RG9M5jkK)

  cursor: isDragging ? '-webkit-grabbing' : '-webkit-grab',

provided.placeholder in a table

To add the provided.placeholder for a table row the tr and provided.placeholder need to be wrapped in a div but this messes up the rows format. Any recommendations on what to do here?

<tbody>
rowList.map((key) => (
    <Draggable
        key={key}
        draggableId={key}
    >
        {(provided, snapshot) => (
            <div> // need to wrap in div to add the placeholder
                <tr>...</tr>
                {provided.placeholder}
            </div>
        ))}
    </Draggable>
)
</tbody>

styled-components v4 compat

Bug or feature request?

Bug

Expected behaviour

I should be able to use styled components as draggable and droppable elements.

Actual behaviour

Console error: Uncaught TypeError: el.getBoundingClientRect is not a function

Steps to reproduce

                  <Draggable key={key} draggableId={key}>
                    {(dprovided, snapshot) =>
                        <StyledComponent
                          ref={dprovided.innerRef}
                          style={dprovided.draggableStyle}
                          {...dprovided.dragHandleProps}
                        >

Demo

https://www.webpackbin.com/bins/-KrfYRa9483PnZVAbgvL

Dragging big items

Currently to decide which item should go on top when dragging an item from one list to another, we compare the centre positions. However, this often ends up punishing large items and they almost always move below their target. Perhaps we should change the comparison to check the start edge rather than the centre position to see which goes on top. This would therefore not take the size of the item into account and would not punish large items

Your thoughts @jaredcrowe ?

Add a real browser test

I am not sure if we need this - but I thought I would raise it anyway

Generally I am quite against browser tests. However, I think it could be worthwhile having one smoke test that runs in a real browser. I am fairly keen to use puppeteer for this one. It would not need to run in all browsers. This is purely just a small smoke test.

Criteria

  • Would need to be able to run on travis (I think if we run chrome in headless mode this should be fine)
  • Needs to be crazy simple with minimal config - I do not want to spend heaps of time maintaining this.

Remove placeholder from API once upgraded to React 16

Droppable API

<Droppable droppableId="droppable-1">
  {(provided, snapshot) => (
    <div ref={provided.innerRef}>
      Good to go
    </div>
  )}
</Droppable>

Proposed change: rather that requiring the consumer to bind the ref - use ReactDOM.find(this) to get the DOM node.

New usage

<Droppable droppableId="droppable-1">
  {(provided, snapshot) => (
    <div>
      Good to go
    </div>
  )}
</Droppable>

Draggable API

<Draggable draggableId="draggable-1">
  {(provided, snapshot) => (
    <div>
      <div
        ref={provided.innerRef}
        style={provided.draggableStyle}
        {...provided.dragHandleProps}
      >
        Drag me!
      </div>
      {provided.placeholder}
    </div>
  )}
</Draggable>
```js

Again, rather than the user needing to manually return the ref - just use ReactDOM to get it.
Also - placeholder will be come a dynamically added sibling to the root node rather than needing to be put into the react tree by the consumer. However, this needs to wait until we upgrade to React 16 so that we can return siblings without a wrapping element.

**new usage:**

```js
<Draggable draggableId="draggable-1">
  {(provided, snapshot) => (
      <div
        style={provided.draggableStyle}
        {...provided.dragHandleProps}
      >
        Drag me!
      </div>
  )}
</Draggable>

Unknown plugin `transform-runtime' error in a React-Native app

Bug

First of all, I'm super noob so maybe this error is obvious.
I tried to use this in an React-Native app I'm developing. But It shows this error.

Unknown plugin transform-runtime' `

then I tried to fix using

npm install babel-plugin-transform-runtime

then it turns to this

`TransformError: /Users/Adalbert/project/QuestLog - todolist/build/QUESTLOG/node_modules/react-beautiful-dnd/lib/index.js: [BABEL] /Users/Adalbert/project/QuestLog - todolist/build/QUESTLOG/node_modules/react-beautiful-dnd/lib/index.js: Unknown option: /Users/Adalbert/project/QuestLog - todolist/build/QUESTLOG/node_modules/react/index.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
{ presets: [{option: value}] }
Valid:
{ presets: [['presetName', {option: value}]] }

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options. (While processing preset: "/Users/Adalbert/project/QuestLog - todolist/build/QUESTLOG/node_modules/react/index.js")

ABI19_0_0RCTFatal
ABI19_0_0RCTSetFatalHandler
ABI19_0_0RCTSetFatalHandler


_dispatch_main_queue_callback_4CF


CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
Exponent
`

I'm quite sure this error is an noob error but I couldn't find answer anywhere that can solve it.
So I hope someone here can help? Really appreciate your helping.

Also thanks for sharing this awesome package. Love to see more of it soon.

Drag&Drop works incorrectly for scrollable container

Bug

Demo: http://g.recordit.co/Ep9vM3PPeq.gif

Drag&Drop for cards from the last column does not work correctly. Seems scroll is not taken into account

Expected behavior

Drag&Drop should work in same way with or without scroll

Actual behavior

Drag&Drop for cards which exceed initially scrollable screen is working incorrectly. Gif shows this behavior http://g.recordit.co/Ep9vM3PPeq.gif
ep9vm3ppeq

Steps to reproduce

  1. Open https://react-beautiful-dnd.netlify.com/?selectedKind=board&selectedStory=task%20board&full=0&down=1&left=1&panelRight=0&downPanel=storybook%2Factions%2Factions-panel
  2. Resize screen to move the last board column outside of screen
  3. Pick up card from the last column
  4. Card would be ranking inside incorrect column

Browser version

  • Chrome for Mac Version 60.0.3112.113 (Official Build) (64-bit)
  • Latest Firefox for Mac

Demo

http://g.recordit.co/Ep9vM3PPeq.gif

Keyboard reordering does not work correctly when dragging a huge item

Bug or feature request?

Bug

Expected behaviour

When I reorder a list with different sized items with a keyboard it should reorder correctly.

Actual behaviour

If the item dragging is more that double the height of the next item then:

  • the dragging item moves into the correct position
  • the non dragging item does not move into its new location

Steps to reproduce

  • Start a keyboard drag with an item that is more than double the height of the one next to it
  • try to drag past the next item

Demo

https://www.webpackbin.com/bins/-KsCUEpbt2X70IoQmbhj

Throw error if Draggable has an invalid type

Currently we only support Draggables to have the same type as their parent Droppable. However, we do not log this error until the user starts dragging. We could do this in advance by putting the Droppables type on the context as well as its id which is already there

Animated placeholders when transitioning between lists

When transitioning between lists there is some snapping that occurs:

  • when entering a new list the placeholder snaps to the correct height without animating
  • when dropping in a foreign list, the original placeholder in the home list does not animate and disappears instantly when the drop completes

The goal is to have both of these scenarios animated. However, in order to ship #2 it was decided that this feature was not critical enough to hold up the release. The interaction still feels really nice - it would just be even better with animated placeholders.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.