-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Experiment: support for non-contiguous blocks in selection #3584
Conversation
This sounds very interesting and cool, though I can't quite get it to work (Mac / Chrome). I can click one block, hold shift and click another, and select all in between. But Ctrl clicking does nothing for me. Am I doing it wrong? |
Probably not. I was only testing on Linux at this stage (dev env), so the Cmd/Ctrl key switching hasn't been done. Or it could be something else. |
I tried both the ⌘ and CTRL buttons, neither did anything. However if you can screen record perhaps we can take a look at that. |
Ctrl+Click works on Windows for me, tested with Firefox and Chrome. However, on macOS, it opens the browser contextual menu. Quick suggestion: in WordPress, when adding Media in a post, it is possible to do a multi-selection in the attachments grid pressing Ctrl+Spacebar. It would be nice to use the same keys for keyboard multi-selection. |
OK, so this is an updated version. Still a POC.
Things that have hacky workarounds
Things that are not implemented
|
@jasmussen should work on Mac now... |
Nice work. Here's what it looks like on Mac: I don't know if we can force the context menu to not show, though, so if we were to take this further we'd want to use ⌘ instead on the mac. This works well. In another track we are exploring the navigation/edit mode, where when you click a block you are in edit mode, when you press escape you are in navigation mode, and in navigation mode you can also select non-contiguous blocks with the keyboard. The question is then — are those two appraoches complementary? Can they be merged? If they were, would the click gestures in this branch invoke navigation mode, so you could for example start selecting with the mouse and then continue on with using the keyboard? |
If the other track was #3195, then this approach is mostly focusing on the non-contiguous blocks side of it, whereas that branch was about focus and tabbing. This PR also has support for pressing Escape and Enter to switch between Editing and Navigation mode. So this PR does many of the things the previous one did, but doesn't support Tab at all in any way, because there wasn't current agreement on how it should be handled. Note, you need to use the Cmd key for clicking and the Ctrl key for space to avoid Mac shortcuts. That is implemented already. Ctrl click will work as well, but will open the context menu as you saw. Cmd + space opens spotlight, so you need to use Ctrl+space instead. I'll attach a video (on a Mac) of the various interactions being prototyped. Everything is possible with the keyboard, and everything except adding a range to an existing range is possible with the mouse (with the keyboard, it's Cmd/Ctrl + Shift + arrow keys). The video has the keys being pressed in the bottom left corner. A key idea here is that the focus with the keyboard can move away from a selected block. Also, as soon as you have a multi-selection of any kind, you automatically enter navigation mode. Note, the unintentional scrolling is due to the space event not having a |
Thanks for the info. And thanks for tackling such a difficult aspect. I think it's very promising.
Note that ⌘ + Space to open spotlight requires you hold ⌘ while pressing Space. Just to clarify a bit, here's how I imagine non-contiguous block selection using the keyboard should work:
The behavior is basically that of a list of checkboxes, only if you could arrow-key between them. Space on a checkbox toggles it, space again untoggles it. |
Yep, at the moment you have to hold control to do that. If you hit space by itself, it will deselect everything else as well. This can be changed easily, but was an attempt to match:
As I said, it's easily changed. Making space always toggle and not clear the other selection can be done. You'd just have to make sure you had to way to easily remove all the other selections as well. |
@afercia can you clarify this interaction? I can't get this to work as it sounds like it's intended in the WordPress media library. What's a flow to try this? |
Tested a bit and having the ability to multi select with the keyboard is just amazing 🙂 thanks! There are a few things to consider for accessibility:
This could be as simple as using: or something similar on the wrapper div but, again, this should be tested with different browsers/screen readers combos. I'd lean towards splitting these issues in a separate ticket, and address them when this PR will be merged if y'all agree. Happy to see the great job done here 🙂 |
teste a bit more, also on Windows Firefox ESR and Quantum, and sometimes the selection gia keyboard doesn't work very well. Sometimes it selects the previous block, not sure why. |
@jasmussen and @afercia My understanding of the two options being discussed here: Current behaviour and what I thought Afercia wanted:
Jasmussen's preference:
Is this a correct understanding? If so, let me know when you have a consensus on how it should work :) |
That's correct, yes. The idea being that when you are in "navigation mode", each focused block is like a checkbox. The only problem I can see with this is that Space is also used for scrolling. But I still think this makes the most sense. Curious how the other appoach works, I can't get it to work in the media library. |
This pull request appears to have languished and will not be easily reconciled with master. Please feel free to reopen and rebase against the current master, or open a new pull request. |
Description
This is an experiment to explore how to support non-contiguous selected blocks.
How Has This Been Tested?
It's a rough, hacky POC ... so it hasn't :)
Screenshots (jpeg or gifs if applicable):
Types of changes
Ctrl+Click will toggle the selection of a block (and set a new last active block)
Shift+Click will select from the last active block to the current block
Click will focus a block
Arrow keys will move the focus to a block
Shift arrow keys will grow a selection
There is no current way to select a block with the keyboard (except for the existing growing selection with shift arrow keys. We are anticipating selecting a block with the space bar when in navigation mode)
Note, this will also differentiate between a multi-select with one block, and focus in the block. When you have a multi-select with one block, pressing any arrow key will just focus that block normally (as long as you aren't holding shift). This means that we are no longer losing focus when collapsing the selection back to one block.
Issues identified:
The main purpose of this PR is to get this tested (not code reviewed yet) and see if we like the behaviour. The code will all (probably) change once we're sure of what we want.
@jasmussen @afercia , do you like how this feels? It is mostly modelled on how Safari's Finder works.