adopted-ember-addons / ember-light-table

Lightweight, contextual component based table for Ember
http://adopted-ember-addons.github.io/ember-light-table/
MIT License
312 stars 131 forks source link

Row selection has no keyboard support #236

Open les2 opened 7 years ago

les2 commented 7 years ago

One idea is to allow tab to focus on each row. While focused, an enter (or space) press would select that row. If the ctrl / cmd modifier is used when selecting, it would add/remove the row to the existing selection. If shift modifier is used, it would select a range of rows.

While a row is selected, the up and down arrows could move from one row to another (without activating them) -- this is where the shift modifier would be useful.

Row states:

I've built something like this before with angular and it wasn't too bad to implement (but I wasn't working with a general purpose table widget so I could use more hacks and dirty tricks that would be acceptable for a large project).

Would PRs implementing something like this be accepted? I don't really have a ton of time to focus on this right now but perhaps with a little guidance on implementation strategy me or someone else could take a stab at this.

offirgolan commented 7 years ago

Hi there,

I think this will be a solid addition to the table selection features. I'm not really too sure I understand the exact use case for the tab stuff. I feel like the up and down keys should handle that no?

ScottSmix commented 7 years ago

In my experience, the following work bests (with slight changes for Mac like Cmd-A selects all in multiple selection). I would love to have keyboard features. I think there should be a default mapping of keys to events but the default mapping should be configurable.

Navigation (changes the focused row with a visual clue often highlighting):

Multiple selection:

Single selection:

Notes:

les2 commented 7 years ago

update from a recent feature.

i disabled the built in ELT row selection in favor of a checkbox column with a header column with toggle select all checkbox for the following reasons:

note: it was not difficult to implement this. took about an hour, including updating tests, etc.

so an alternative to the current selection method is the checkbox column (assume it has extend selection enhancement i mentioned above and the up/down navigation system proposed by Scott).

thoughts? i can throw up example of this if it would aid the discussion - let me know.

plcarmel commented 7 years ago

I have the same need for keyboard support. However, I thought, too, about the checkboxes idea but they are a little old school for my taste (i.e. they were needed before the AJAX era but not anymore). Beside, they are slower than an "Excel style" selection where you can quickly select a large range of rows with the mouse. I like the suggestions of @ScottSmix for the navigation and selection.

Anyway, I will implement my thing, put up a demo and you guys tell me what you think.

ScottSmix commented 7 years ago

Excellent! I am glad you are going to tackle this!

les2 commented 7 years ago

I agree that the checkboxes feel a little retro.

I too look forward to seeing your demo with keyboard support.

On Tue, Nov 22, 2016, 8:08 PM Pierre-Luc Carmel Biron < notifications@github.com> wrote:

I have the same need for keyboard support. However, I thought, too, about the checkboxes idea but they are a little old school for my taste (i.e. they were needed before the AJAX era but not anymore). Beside, they are slower than an "Excel style" selection where you can quickly select a large range of rows with the mouse. I like the suggestions of @ScottSmix https://github.com/ScottSmix for the navigation and selection.

Anyway, I will implement my thing, put up a demo and you guys tell me what you think.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/offirgolan/ember-light-table/issues/236#issuecomment-262412354, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBEYHwzORtn8_G_F9DCRi6CaPb-YCudks5rA5H9gaJpZM4KeYIW .

plcarmel commented 7 years ago

Sorry it has been a long time. I am working on it full time now. Should be ready anytime soon.

plcarmel commented 7 years ago

Demo: https://plcarmel.github.io/ember-light-table/#/rows/spreadsheet

I will prepare a PR soon.

ScottSmix commented 7 years ago

Demo looking good! It is very much appreciated. A few notes from my perspective (based on my original suggestions):

Using keyboard navigation on a multiple row selection table, shouldn't the spacebar toggle row selection?

In the demo using the navigation keys (like cursor up or down) un-selects a row. I think that should only be the behavior on single row selection. In multiple row selection, the navigation keys should not automatically un-select a selected row (only spacebar should toggle).

plcarmel commented 7 years ago

I was trying to replicate the behavior of a spreadsheet because it is the behavior that I wanted to have in my app. However, I also did a heavy refactoring (but 100% backward compatible) to allow complete customization of the behavior of the keyboard and mouse. This way, we will be able to provide a large number of different behaviors to the users and they will be able to provide their own if the proposed behaviors do not suit them.

So, if you don't like the way it works, don't worry, it can be just one of many possible options.