Open drewharvey opened 3 years ago
I think what you are trying to do here is a bit convoluted and IMO not supported (would need to check with PO). GridPro is about inline editing, which implies that custom fields are placed within the relevant grid cell and have focus. What you want to do here is not inline editing. As such you should move the editing logic out of GridPro. This can be achieved by:
@sissbruecker I see your point. Let me try this approach. Keyboard navigation is the primary reason I am using GridPro, so I need to see if rendering a button breaks keyboard flow.
Put together a small demo that demonstrates the idea outlined above: https://gist.github.com/sissbruecker/b7709c79ca5e6cdf51594285b641cd6b
Keyboard navigation works as long as the focus stays within the grid. The buttons do not interfere with the tab order. To trigger an edit button with the keyboard, focus the cell with the button, hit Enter, which sets focus on the button. Then hit Enter again to trigger the button.
The only issue is that as soon as the dialog opens, the Grid loses focus, and AFAIK it's currently not possible to programmatically:
So after the dialog closes, you would not be able to guide the user back to the place where they initiated the editing.
@sissbruecker this is a great starting point that I will use as a workaround for now. Paralell with the double "Enter" press required, you will also need to double Click in order to activate the Edit button (if you are not using keyboard nav). I still think using the .custom
api with something like this would be nice. Even if you need to manually fire events or whatever to notify the grid of changes.
Paralell with the double "Enter" press required, you will also need to double Click in order to activate the Edit button (if you are not using keyboard nav)
When using a custom renderer with addColumn
, the button is immediately visible and clickable for all rows, so it's just a single click. For keyboard navigation I understand that it seems bothersome to require multiple key presses, but I think it's part of making the Grid hierarchy properly accessible with the keyboard.
Paralell with the double "Enter" press required, you will also need to double Click in order to activate the Edit button (if you are not using keyboard nav)
When using a custom renderer with
addColumn
, the button is immediately visible and clickable for all rows, so it's just a single click. For keyboard navigation I understand that it seems bothersome to require multiple key presses, but I think it's part of making the Grid hierarchy properly accessible with the keyboard.
That is what I would expect, but the actual behavior requires two clicks.
@sissbruecker do you know if this issue is difficult to fix? I understand the GridPro's main use cases are: inline editing and keyboard navigation. However, real-world apps are going to need a little more flexibility. In my opinion, it is odd that custom editors don't work specifically with dialogs, even if the ux/solution feels conveluted.
The workaround you provided works, but the column implementations can get very complicated, when actual real-world requirements are factored in, and it doesn't feel very maintainable. It also is awkward to have a mixture of GridPro editors used appropriately, and these sort of renderer hacks. I'm struggling to come up with a reusable design and I feel the developers that need to maintain this code will not be happy.
Note - ComponentRenderer workaround does not trigger listeners added via grid.addCellEditStartedListener
Description
Using a
CustomField<String>
as a custom editor in GridPro works as expected. However, if you wrap the fields in a Dialog the editor does not get/set the values correctly.Live Demo (optional)
Minimal reproducible example
Working (not Dialog):
Not working (fields wrapped in Dialog):
Environment
Vaadin: 22.0.0.alpha5
OSX 11.6
Browsers Affected
Only tested in Chrome