-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
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 3d9823f
initial
alexreardon 26405fd
basic scroll window down version
alexreardon 9fb48cb
wip
alexreardon 77e8686
fiddling with auto scroll for touch
alexreardon 5eff709
wip
alexreardon 317ed80
prototype of window scroll working
alexreardon e2825b6
fiddling
alexreardon 2d99b9d
wip
alexreardon 9bf1100
detecting frame over
alexreardon 316aacc
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon 18e4a1a
wip
alexreardon db199bd
as good as we can do
alexreardon a8993ef
uncommenting droppable code
alexreardon 47962de
scroll handover
alexreardon 2742d41
minor
alexreardon 97cd95b
adding DroppableProps type
alexreardon aa20b59
fixing incorrect droppable offset due to scroll on drop
alexreardon c5cef97
adding comment
alexreardon 5338ad4
progress
alexreardon 3003c72
more is too big logic
alexreardon 6a97c5b
correcting keyboard window scrolling
alexreardon b9946f9
progress
alexreardon a2858bb
giving more information for scroll jumping
alexreardon ac909e9
more fiddling
alexreardon db45ca6
in home list seems to be working
alexreardon f538ced
in home list is looking niace
alexreardon a1e8ab1
correcting droppable scroll
alexreardon 2e0f1f1
new droppable dimension type
alexreardon 6f87401
responding to type refactor
alexreardon a3a3037
streamlined scroll logic checks
alexreardon a4295fe
using easing function for fluid scroll
alexreardon 6943be0
updating auto scroll config values
alexreardon 4514c1e
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon e6385ba
initial
alexreardon 6c8888a
its alive
alexreardon da03a2b
foreign list is almost working
alexreardon 75461e9
using a map for keyblocking
alexreardon e156fbb
adding cancel for keyboard on touchstart
alexreardon 2cf9228
minor cleanup
alexreardon 2b746a2
wip
alexreardon 83c709b
progress
alexreardon d1aa5b7
progress?
alexreardon c0ecedb
it is working better
alexreardon 85045e1
removing comment
alexreardon 1c06e5c
floor to round
alexreardon b823164
splitting out auto scroll marshal
alexreardon b15cd43
more fiddling
alexreardon 0cce097
initial tests
alexreardon e8d36aa
streamlining logic for overflow
alexreardon 9ee75c7
continuing with tests
alexreardon ebc9881
moving window functions
alexreardon 6b6b112
finialising can-scroll tests
alexreardon c355628
cleaning up can scroll file
alexreardon 015b7ab
setup for auto scroll tests
alexreardon 193705c
more tests
alexreardon 2da64cc
adding tests
alexreardon 53584bf
more tests
alexreardon e5d9b98
tests for cross axis scrolling
alexreardon 597cfd4
about to try something cray
alexreardon c2c0882
simplifying some tests
alexreardon cc45e7d
droppable scroll tests
alexreardon 7df62d0
more tests
alexreardon 1226887
more tests for cross axis droppable scrolling
alexreardon 535b1b5
renaming axis property
alexreardon 314de42
fixing test
alexreardon ea8d32d
structure
alexreardon 2bd7324
finalising fluid scroll tests
alexreardon f435028
cleaning up
alexreardon 08bb3c1
jump scroller tests
alexreardon 61d4eb8
finalising tests for jump window scrolling
alexreardon 275e903
skelton for jump droppable tests
alexreardon fa1ce2d
jump scroller tests
alexreardon 95d7812
more jump scrolling tests
alexreardon c0ec779
renaming files
alexreardon 361cdd2
finalising jump move tests
alexreardon 23cf7f2
trying something different
alexreardon fcd3296
fixing scroll target
alexreardon 7b3734f
removing logs
alexreardon a4d890c
removing some logging
alexreardon 1955e40
initial
alexreardon 273645c
wirering
alexreardon ff0d893
fixing hook tests
alexreardon 26b3ce4
adding tests
alexreardon 27224f4
more tests for hooks
alexreardon d556f87
minor improvements
alexreardon c11e3f5
goodbye aria-grabbed
alexreardon 561a363
changing shape
alexreardon 93d062c
fixing tests
alexreardon c66c2b7
adding some accessibility stories
alexreardon d31ef1b
pretty example
alexreardon bf92c13
improvements
alexreardon ccf8513
improving accessibility story
alexreardon 1de1cc5
adding tests for announcer
alexreardon 4bf2486
progress
alexreardon 1af4d22
adding default screen reader messages
alexreardon 6f01b78
new api and cleanup
alexreardon 761c184
adding some blue
alexreardon 9f3f162
jump scroll just got some love
alexreardon 15812e9
things are looking better
alexreardon 88710b1
streamlining scroll displacement calcs
alexreardon f581db3
adding todo
alexreardon ddde53e
new api. fixing hook tests
alexreardon 8f7a958
more annoucement tests
alexreardon b84c34a
more annoucement tests
alexreardon 00592f1
more announcements checks
alexreardon b0aa6d1
tests added
alexreardon d555480
streamlining conditional annoucements in hook caller
alexreardon a5b2bc0
fixing bug where mouse dragging would initially publish incorrect val…
alexreardon d2c9e98
updating dimension tests
alexreardon 8034a92
simplying hook-caller
alexreardon 437ea6e
updating tests for spacing
alexreardon cf94e0c
updating get-drag-impact tests
alexreardon 93333c9
updating dimension marshal tests
alexreardon 095e109
reordering bulk publish params
alexreardon 376ab17
progress
alexreardon 7e5148e
progress
alexreardon 6d6d2e2
fixing visible edge displacement
alexreardon 4bccd13
cleaning up comment
alexreardon 5af81b5
correcting partial scrolling algorithm
alexreardon 3cf7904
fixing move-to-next-index tests
alexreardon 85816c5
fixing flow
alexreardon 8727a3c
fixing tests for canscroll
alexreardon b535d7c
comment
alexreardon 0476309
initial
alexreardon b41bb48
fixed
alexreardon 61ceaee
updating fluid scoller tests. making state preset axis aware
alexreardon 77948a1
state preset is now axis aware
alexreardon f19ce05
tests for everyone
alexreardon ff59db0
get-closest-draggable tests
alexreardon 48bf586
testing scroll displacement in move-to-new-droppable
alexreardon 183bfd7
fixing import
alexreardon e3cce55
unconnected draggable tests
alexreardon a154c72
fixing connected draggable tests
alexreardon 950aebf
more tests
alexreardon e2ffd6b
updating connected droppable
alexreardon f8f23fc
more testing
alexreardon ceb0065
moving from index to map for interactive element lookup
alexreardon 80741cf
new forced visibility displacement
alexreardon 2b7cffe
force push progress
alexreardon 6d1a9e9
initial
alexreardon 0827090
fixing keyboard displacement when moving closer to the start position
alexreardon db1ddf4
tests and docs
alexreardon b189cd5
fixing more tests
alexreardon 6dbd32f
fixing more tests
alexreardon 436ce4f
more docs and tests
alexreardon dad905b
immediate droppable scrolling for keyboard dragging
alexreardon 8708b7e
tests for scroll options
alexreardon 249f6cb
more tests
alexreardon 2c8d1e2
more tests. more green
alexreardon c4ec91c
removing comment
alexreardon 549723a
Merge remote-tracking branch 'origin/master' into auto-scroll
alexreardon 06168c3
updating docs
alexreardon d9bb350
improved logic for opting out of auto scrolling
alexreardon 42191ad
attempt 1
alexreardon 0b01ac0
removing is too big logic from jump scroller (it is not needed)
alexreardon 6010f90
new improved experience for big items
alexreardon bd04af7
more tests
alexreardon 8b68af5
removing unneeded jump scroller tests
alexreardon fb8e3bc
shuffling code around
alexreardon 6fde4d2
improvements to docs and screen-reader guide
alexreardon da2b9ce
simplified jump-scroll logic
alexreardon f5c5ab1
fixing comment
alexreardon e641884
minor changes in response to PR feedback
alexreardon c8a1146
removing comment
alexreardon 9763762
improving comment
alexreardon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Screen reader guide | ||
|
||
`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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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