Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto scrolling (and more!) #321

Merged
merged 166 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
31f36aa
reshaping droppable dimension for clarity
alexreardon Jan 16, 2018
3d9823f
initial
alexreardon Jan 17, 2018
26405fd
basic scroll window down version
alexreardon Jan 18, 2018
9fb48cb
wip
alexreardon Jan 18, 2018
77e8686
fiddling with auto scroll for touch
alexreardon Jan 18, 2018
5eff709
wip
alexreardon Jan 18, 2018
317ed80
prototype of window scroll working
alexreardon Jan 18, 2018
e2825b6
fiddling
alexreardon Jan 18, 2018
2d99b9d
wip
alexreardon Jan 19, 2018
9bf1100
detecting frame over
alexreardon Jan 19, 2018
316aacc
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Jan 21, 2018
18e4a1a
wip
alexreardon Jan 21, 2018
db199bd
as good as we can do
alexreardon Jan 23, 2018
a8993ef
uncommenting droppable code
alexreardon Jan 23, 2018
47962de
scroll handover
alexreardon Jan 24, 2018
2742d41
minor
alexreardon Jan 24, 2018
97cd95b
adding DroppableProps type
alexreardon Jan 24, 2018
aa20b59
fixing incorrect droppable offset due to scroll on drop
alexreardon Jan 24, 2018
c5cef97
adding comment
alexreardon Jan 24, 2018
5338ad4
progress
alexreardon Jan 25, 2018
3003c72
more is too big logic
alexreardon Jan 28, 2018
6a97c5b
correcting keyboard window scrolling
alexreardon Jan 28, 2018
b9946f9
progress
alexreardon Jan 29, 2018
a2858bb
giving more information for scroll jumping
alexreardon Jan 29, 2018
ac909e9
more fiddling
alexreardon Jan 29, 2018
db45ca6
in home list seems to be working
alexreardon Jan 29, 2018
f538ced
in home list is looking niace
alexreardon Jan 29, 2018
a1e8ab1
correcting droppable scroll
alexreardon Jan 29, 2018
2e0f1f1
new droppable dimension type
alexreardon Jan 29, 2018
6f87401
responding to type refactor
alexreardon Jan 29, 2018
a3a3037
streamlined scroll logic checks
alexreardon Jan 30, 2018
a4295fe
using easing function for fluid scroll
alexreardon Jan 30, 2018
6943be0
updating auto scroll config values
alexreardon Jan 30, 2018
4514c1e
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Jan 30, 2018
e6385ba
initial
alexreardon Jan 30, 2018
6c8888a
its alive
alexreardon Jan 30, 2018
da03a2b
foreign list is almost working
alexreardon Jan 31, 2018
75461e9
using a map for keyblocking
alexreardon Jan 31, 2018
e156fbb
adding cancel for keyboard on touchstart
alexreardon Jan 31, 2018
2cf9228
minor cleanup
alexreardon Jan 31, 2018
2b746a2
wip
alexreardon Jan 31, 2018
83c709b
progress
alexreardon Jan 31, 2018
d1aa5b7
progress?
alexreardon Feb 1, 2018
c0ecedb
it is working better
alexreardon Feb 1, 2018
85045e1
removing comment
alexreardon Feb 1, 2018
1c06e5c
floor to round
alexreardon Feb 1, 2018
b823164
splitting out auto scroll marshal
alexreardon Feb 1, 2018
b15cd43
more fiddling
alexreardon Feb 2, 2018
0cce097
initial tests
alexreardon Feb 2, 2018
e8d36aa
streamlining logic for overflow
alexreardon Feb 2, 2018
9ee75c7
continuing with tests
alexreardon Feb 3, 2018
ebc9881
moving window functions
alexreardon Feb 4, 2018
6b6b112
finialising can-scroll tests
alexreardon Feb 4, 2018
c355628
cleaning up can scroll file
alexreardon Feb 4, 2018
015b7ab
setup for auto scroll tests
alexreardon Feb 4, 2018
193705c
more tests
alexreardon Feb 5, 2018
2da64cc
adding tests
alexreardon Feb 5, 2018
53584bf
more tests
alexreardon Feb 5, 2018
e5d9b98
tests for cross axis scrolling
alexreardon Feb 5, 2018
597cfd4
about to try something cray
alexreardon Feb 5, 2018
c2c0882
simplifying some tests
alexreardon Feb 6, 2018
cc45e7d
droppable scroll tests
alexreardon Feb 6, 2018
7df62d0
more tests
alexreardon Feb 6, 2018
1226887
more tests for cross axis droppable scrolling
alexreardon Feb 6, 2018
535b1b5
renaming axis property
alexreardon Feb 6, 2018
314de42
fixing test
alexreardon Feb 6, 2018
ea8d32d
structure
alexreardon Feb 6, 2018
2bd7324
finalising fluid scroll tests
alexreardon Feb 6, 2018
f435028
cleaning up
alexreardon Feb 6, 2018
08bb3c1
jump scroller tests
alexreardon Feb 7, 2018
61d4eb8
finalising tests for jump window scrolling
alexreardon Feb 7, 2018
275e903
skelton for jump droppable tests
alexreardon Feb 7, 2018
fa1ce2d
jump scroller tests
alexreardon Feb 7, 2018
95d7812
more jump scrolling tests
alexreardon Feb 7, 2018
c0ec779
renaming files
alexreardon Feb 7, 2018
361cdd2
finalising jump move tests
alexreardon Feb 7, 2018
23cf7f2
trying something different
alexreardon Feb 7, 2018
fcd3296
fixing scroll target
alexreardon Feb 7, 2018
7b3734f
removing logs
alexreardon Feb 7, 2018
a4d890c
removing some logging
alexreardon Feb 7, 2018
1955e40
initial
alexreardon Feb 7, 2018
273645c
wirering
alexreardon Feb 7, 2018
ff0d893
fixing hook tests
alexreardon Feb 8, 2018
26b3ce4
adding tests
alexreardon Feb 8, 2018
27224f4
more tests for hooks
alexreardon Feb 8, 2018
d556f87
minor improvements
alexreardon Feb 8, 2018
c11e3f5
goodbye aria-grabbed
alexreardon Feb 8, 2018
561a363
changing shape
alexreardon Feb 8, 2018
93d062c
fixing tests
alexreardon Feb 8, 2018
c66c2b7
adding some accessibility stories
alexreardon Feb 8, 2018
d31ef1b
pretty example
alexreardon Feb 8, 2018
bf92c13
improvements
alexreardon Feb 8, 2018
ccf8513
improving accessibility story
alexreardon Feb 8, 2018
1de1cc5
adding tests for announcer
alexreardon Feb 8, 2018
4bf2486
progress
alexreardon Feb 8, 2018
1af4d22
adding default screen reader messages
alexreardon Feb 8, 2018
6f01b78
new api and cleanup
alexreardon Feb 8, 2018
761c184
adding some blue
alexreardon Feb 11, 2018
9f3f162
jump scroll just got some love
alexreardon Feb 11, 2018
15812e9
things are looking better
alexreardon Feb 11, 2018
88710b1
streamlining scroll displacement calcs
alexreardon Feb 11, 2018
f581db3
adding todo
alexreardon Feb 11, 2018
ddde53e
new api. fixing hook tests
alexreardon Feb 12, 2018
8f7a958
more annoucement tests
alexreardon Feb 12, 2018
b84c34a
more annoucement tests
alexreardon Feb 12, 2018
00592f1
more announcements checks
alexreardon Feb 12, 2018
b0aa6d1
tests added
alexreardon Feb 12, 2018
d555480
streamlining conditional annoucements in hook caller
alexreardon Feb 12, 2018
a5b2bc0
fixing bug where mouse dragging would initially publish incorrect val…
alexreardon Feb 12, 2018
d2c9e98
updating dimension tests
alexreardon Feb 12, 2018
8034a92
simplying hook-caller
alexreardon Feb 12, 2018
437ea6e
updating tests for spacing
alexreardon Feb 12, 2018
cf94e0c
updating get-drag-impact tests
alexreardon Feb 13, 2018
93333c9
updating dimension marshal tests
alexreardon Feb 13, 2018
095e109
reordering bulk publish params
alexreardon Feb 13, 2018
376ab17
progress
alexreardon Feb 13, 2018
7e5148e
progress
alexreardon Feb 13, 2018
6d6d2e2
fixing visible edge displacement
alexreardon Feb 13, 2018
4bccd13
cleaning up comment
alexreardon Feb 13, 2018
5af81b5
correcting partial scrolling algorithm
alexreardon Feb 13, 2018
3cf7904
fixing move-to-next-index tests
alexreardon Feb 13, 2018
85816c5
fixing flow
alexreardon Feb 13, 2018
8727a3c
fixing tests for canscroll
alexreardon Feb 13, 2018
b535d7c
comment
alexreardon Feb 13, 2018
0476309
initial
alexreardon Feb 14, 2018
b41bb48
fixed
alexreardon Feb 14, 2018
61ceaee
updating fluid scoller tests. making state preset axis aware
alexreardon Feb 15, 2018
77948a1
state preset is now axis aware
alexreardon Feb 15, 2018
f19ce05
tests for everyone
alexreardon Feb 15, 2018
ff59db0
get-closest-draggable tests
alexreardon Feb 15, 2018
48bf586
testing scroll displacement in move-to-new-droppable
alexreardon Feb 15, 2018
183bfd7
fixing import
alexreardon Feb 15, 2018
e3cce55
unconnected draggable tests
alexreardon Feb 15, 2018
a154c72
fixing connected draggable tests
alexreardon Feb 15, 2018
950aebf
more tests
alexreardon Feb 15, 2018
e2ffd6b
updating connected droppable
alexreardon Feb 15, 2018
f8f23fc
more testing
alexreardon Feb 16, 2018
ceb0065
moving from index to map for interactive element lookup
alexreardon Feb 18, 2018
80741cf
new forced visibility displacement
alexreardon Feb 18, 2018
2b7cffe
force push progress
alexreardon Feb 18, 2018
6d1a9e9
initial
alexreardon Feb 19, 2018
0827090
fixing keyboard displacement when moving closer to the start position
alexreardon Feb 19, 2018
db1ddf4
tests and docs
alexreardon Feb 19, 2018
b189cd5
fixing more tests
alexreardon Feb 19, 2018
6dbd32f
fixing more tests
alexreardon Feb 19, 2018
436ce4f
more docs and tests
alexreardon Feb 19, 2018
dad905b
immediate droppable scrolling for keyboard dragging
alexreardon Feb 20, 2018
8708b7e
tests for scroll options
alexreardon Feb 20, 2018
249f6cb
more tests
alexreardon Feb 20, 2018
2c8d1e2
more tests. more green
alexreardon Feb 20, 2018
c4ec91c
removing comment
alexreardon Feb 20, 2018
549723a
Merge remote-tracking branch 'origin/master' into auto-scroll
alexreardon Feb 20, 2018
06168c3
updating docs
alexreardon Feb 20, 2018
d9bb350
improved logic for opting out of auto scrolling
alexreardon Feb 21, 2018
42191ad
attempt 1
alexreardon Feb 21, 2018
0b01ac0
removing is too big logic from jump scroller (it is not needed)
alexreardon Feb 21, 2018
6010f90
new improved experience for big items
alexreardon Feb 21, 2018
bd04af7
more tests
alexreardon Feb 21, 2018
8b68af5
removing unneeded jump scroller tests
alexreardon Feb 21, 2018
fb8e3bc
shuffling code around
alexreardon Feb 21, 2018
6fde4d2
improvements to docs and screen-reader guide
alexreardon Feb 22, 2018
da2b9ce
simplified jump-scroll logic
alexreardon Feb 22, 2018
f5c5ab1
fixing comment
alexreardon Feb 22, 2018
e641884
minor changes in response to PR feedback
alexreardon Feb 22, 2018
c8a1146
removing comment
alexreardon Feb 22, 2018
9763762
improving comment
alexreardon Feb 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 202 additions & 92 deletions README.md

Large diffs are not rendered by default.

163 changes: 163 additions & 0 deletions docs/guides/screen-reader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Screen reader guide
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this guide is still a WIP


`react-beautiful-dnd` ships with great screen reader support in english out of the box 📦! So if you are looking to just get started there is nothing you need to do.

However, you have total control over all of the messages. This allows you to tailor the messaging for your particular usages as well as for internationalisation purposes.

This guide has been written to assist you in creating your own messaging that is functional and delights users. It is possible for a user who is using a screen reader to use any input type. However, we have the screen reader experience to be focused on keyboard interactions.

## Tone

For the default messages we have gone for a friendly tone. We have also chosen to use personal language; preferring phases such as 'You have dropped the item' over 'Item dropped'. It is a little more wordy but is a friendlier experience. You are welcome to choose your own tone for your messaging.

## How to control announcements

The `announce` function that is provided to each of the `DragDropContext` > `Hook` functions can be used to provide your own screen reader message. This message will be immediately read out. In order to provide a fast and responsive experience to users **you must provide this message synchronously**. If you attempt to hold onto the `announce` function and call it later it will not work and will just print a warning to the console. Additionally, if you try to call `announce` twice for the same event then only the first will be read by the screen reader with subsequent calls to `announce` being ignored and a warning printed.

## Step 1: lift instructions

When a user `tabs` to a `Draggable` we need to instruct them on how they can start a drag. We do this by using the `aria-roledescription` property on a `drag handle`.

**Default message**: "Draggable item. Press space bar to lift"

Things to note:

- We tell the user that the item is draggable
- We tell the user how they can start a drag

We do not give all the drag movement instructions at this point as they are not needed until a user starts a drag.

The **default** message is fairly robust, however, you may prefer to substitute the word "item" for a noun that more closely matches your problem domain, such as "task" or "issue". You may also want to drop the word "item" altogether.

## Step 2: drag start

When a user lifts a `Draggable` by using the `spacebar` we want to tell them a few things:

- they have lifted the item
- what position the item is in
- how to move the item around

**Default message**: "You have lifted an item in position ${start.source.index + 1}. Use the arrow keys to move, space bar to drop, and escape to cancel."

By default we do not say they are in position `1 of x`. This is because we do not have access to the size of the list in the current api. We have kept it like this for now to keep the api light and future proof as we move towards virtual lists. You are welcome to add the `1 of x` language yourself if you like!

You may also want to say what list the item is in and potentially the index of the list.

Here is an message that has a little more information:

"You have lifted an item in position ${startPosition} of ${listLength} in the ${listName} list. Use the arrow keys to move, space bar to drop, and escape to cancel."

You can control the message printed to the user by using the `DragDropContext` > `onDragStart` hook

```js
onDragStart = (start: DragStart, provided: HookProvided) => {
provided.announce('My super cool message');
}
```

## Step 3: drag movement

When something changes in response to a user interaction we want to announce the current state of the drag to the user. There are a lot of different things that can happen so we will need a different message for these different stages.

We can control the announcement by using the `DragDropContext` > `onDragUpdate` hook.

```js
onDragUpdate = (update: DragUpdate, provided: HookProvided) => {
provided.announce('Update message');
}
```

### Moved in the same list

In this scenario the user has moved backwards or forwards within the same list. We want to instruct the user what position they are now in.

**Default message**: "You have moved the item to position ${update.destination.index + 1}".

You may also want to include `of ${listLength}` in your messaging.

### Moved into a different list

In this case we want to tell the user

- they have moved to a new list
- some information about the new list
- what position they have moved from
- what position they are now in

**Default message**: "You have moved the item from list ${update.source.droppableId} in position ${update.source.index + 1} to list ${update.destination.droppableId} in position ${update.destination.index + 1}".

You will probably want to change this messaging to use some friendly text for the name of the droppable. It would also be good to say the size of the lists in the message

Suggestion:

"You have moved the item from list ${sourceName} in position ${lastIndex} of ${sourceLength} to list ${destinationName} in position ${newIndex} of ${destinationLength}".

### Moved over no list

While this is not possible to do with a keyboard, it is worth having a message for this in case a screen reader user is using a pointer for dragging.

You will want to simply explain that they are not over a droppable area.

**Default message**: "You are currently not dragging over a droppable area".

## Step 3: on drop

In this phase we give a small summary of what the user has achieved.

There are two ways a drop can occur. Either the drag was cancelled or the user released the dragging item. You are able to control the messaging for these events using the `DragDropContext` > `onDragEnd` hook.

### Cancel

A `DropResult` object has a `reason` property which can either be `DROP` or `CANCEL`. You can use this to announce your cancel message.

```js
onDragEnd = (result: DropResult, provided: HookProvided) => {
if(result.reason === 'CANCEL') {
provided.announce('Your cancel message');
return;
}
}
```

This announcement should:

- Inform the user that the drag have been cancelled
- Let the user know where the item has returned to

**Default message**: "Movement cancelled. The item has returned to its starting position of ${result.source.index + 1}"

You are also welcome to add information about the size of the list, and the name of the list you have dropped into.

**Suggestion** "Movement cancelled. The item has returned to list ${listName} to its starting position of ${startPosition} of ${listLength}".

### Drop in the home list

This announcement should:

- Inform the user that they have completed the drag
- Let them know what position the item is in now

**Default message**: "You have dropped the item. It has moved from position ${result.source.index + 1} to ${result.destination.index + 1}"

You may also want to provide a different message if they drop in the same position that they started in.

**Default message**: "You have dropped the item. It has been dropped on its starting position of ${result.source.index + 1}"

### Drop in a foreign list

The messaging for this scenario should be similar to that of dropping in the home list, with the additional information of what list the item started in and where it finished.

**Default message**: "You have dropped the item. It has moved from position ${result.source.index + 1} in list ${result.source.droppableId} to position ${result.destination.index + 1} in list ${result.destination.droppableId}"

You may want to extend this to include the name of the `Droppable` rather than the id. Also, if your `Droppable`s are ordered you may also want to include some positioning information.

### Drop on no destination

It is possible for a user to drop on no Droppable. This is not possible to do with a keyboard. However, if a user is using a pointer input such as a mouse. Our messaging is geared towards keyboard usage. However, it is a good idea to provide messaging for this scenario also.

In this message you should:

- Let the user know that they dropped while not over a droppable location
- Let them know where the item has returned to

**Default message**: "The item has been dropped while not over a droppable location. The item has returned to its starting position of ${result.source.index + 1}"
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ export type {

// Hooks
DragStart,
DragUpdate,
DropResult,
HookProvided,
Announce,
DraggableLocation,
OnDragStartHook,
OnDragUpdateHook,
OnDragEndHook,
} from './types';

// Droppable
export type {
Provided as DroppableProvided,
StateSnapshot as DroppableStateSnapshot,
DroppableProps,
} from './view/droppable/droppable-types';

// Draggable
Expand Down
Loading