vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
429 stars 82 forks source link

[grid-pro] Allow navigation using arrow keys when in edit mode #413

Open stefanuebe opened 3 years ago

stefanuebe commented 3 years ago

Currently it is not possible to navigate through the GP using the arrow keys while in edit mode, which feels somehow unintuitive (especially when you are used to that behavior from Excel).

Therefore there are two requests (both for when editing a cell in the grid):

1: Using the arrow keys together with Ctrl should navigate to other editable cells similar to the usage of Enter / Tab. When reaching the end of one direction, it should not navigate further, but stay in the current cell.

This feature can be enabled using methods like for instance

and is enabled by default.

2: The GP can be configured to allow the navigation as described in 1) but without using the Ctrl key (thus using the arrow keys alone changes the edited cell) as it is known from Excel / Spreadsheet behavior.

This feature can be enabled using a method like setNavigateByArrowKeysWithoutCtrlWhenEditing(boolean) and is disabled by default.

jouni commented 3 years ago

I see the use case, but I would try to avoid taking Grid Pro closer to being a spreadsheet than what it already is.

We plan to reintroduce the proper Spreadsheet component, and these two components should ideally not have too much overlap in use cases, I think.

To clarify: I’m not dismissing the idea of making keyboard navigation more flexible in Grid Pro. Just pointing out that we should see if the use case is indeed suitable for Grid Pro or whether it would be more natural to use Spreadsheet for it. Grid Pro is more about editing row items, whereas Spreadsheet is a more freeform data structure (at least in my mind at the moment).

stefanuebe commented 3 years ago

In my case the grid pro and its behavior / features are the perfect match for my customer's use case. It combines perfectly the Grid benefits (table behavior, row based data fetching, selection listeners and sorting) and Spreadsheet benefits (well supported cell based navigation and easy to start editing and saving). So to say already 95 % there, only the last bits are missing :)

rolfsmeds commented 3 years ago

Proposal vaadin/vaadin-grid-pro#2 would definitely not be a good idea, as left/right arrow keys are used to move the text cursor in the field, and up/down are used for dropdown fields. I would not want to make that even an optional feature.

Proposal vaadin/vaadin-grid-pro#1 would perhaps be doable, although on macOS ctrl/cmd + arrow keys are typically already reserved, so they would not work for many users, so a different shortcut would be needed, and I can't really imagine what that would be. Besides, we already provde the Enter Next Row mode which let's you navigate vertically in a column with Enter / shift-Enter (and of course Tab/shift-Tab works by default to navigate horizontally in edit mode).