-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Move items with keyboard controls #3092
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
base: master
Are you sure you want to change the base?
Move items with keyboard controls #3092
Conversation
When using the arrow keys the item moves one colum left or right. Or its own height up or down.
The item is moved with the keyboard and the item stays in view of the user.
this is great and will need to take a look, but when using arrow keys we need to move entire elements to either side to replace with, because unlike the mouse we cannot incrementally move and wait for half way point to initiate a move. using arrow keys it shoudl always move in that direction so code needs to check what is say the element above and move itself to the beginning of that element top postion and let the code figure out what it means (swap, push down, etc...). You shoudl be able to do that using update(el) and placing where the other target is instead. |
I tried it with update, and things move around only they move behind the other items they do not update the position of the other elements. I removed all the calls to trigger the mouseEvents. This is what you meant right ? I can probably figure out which items overlap but how to determine the position they need to move to ? we use items with different heights and widths. So it not always as easy to say just swap them around.
} protected _itemPosition(code: string) {
// grid.commit() / grid.save() both dont do anything |
I figured somethings out without using update, maybe it will work with update as well. I will update this branch tomorrow |
Move assignments to the position they are used
I fixed a lot of edge cases we had. |
This takes the selected elements width and its position to check for the first item above. When no direct item is found find the first item in the row above and move the item above that.
First look for the next item in the row directly below the selected item. When nothing is find look for the first item below the selected item. And when that fails because of whitespacing, look for the first item which is below and overlaps the selected item. Also check if the selected item has sibling, because when the item below spans more columns, it can mean there is no space for that item. Instead, move the selected item below the next item.
60ac268
to
78dfd52
Compare
Description
We are trying to get our application to comply to the a11y norm. One of the issues we encountered was that gridstack is not accessible with the keyboard.
A user cannot select and move items around with only the use of a keyboard.
What we have done is reuse the moving of items for the mouse for the keyboard.
This works, except when using items with different heights.
When moving an item up or down and the item above or below has a greater height, then the item does not move.
As we use the items height to move the item, I know that the position is only changed when it moves further than half way the other item. Is there a way we can know how far to move the item to make sure it changes position?
Checklist
yarn test
)