flow-components
flow-components copied to clipboard
Spreadsheet focuses the sheet rather than the component when displaying a cell edit component
Description
When a cell with a custom editor is clicked, the custom editor is displayed instead of (or on top of, hiding) the cell static contents. However, after displaying the editor component, the SheetWidget client-side code sets the focus to the sheet, not the editor.
This line is from the initial code commit 10 years ago, per Git-Blame. To my mind that means there is no institutional knowledge about why that focus choice is there :) I don't remember my 10 year old code, at least.
This causes custom edit component use to require multiple clicks, and even breaks keyboard navigation, as attempting to edit a cell suddenly jumps focus back to the sheet, requiring navigating to the cell once again before the component can be used.
Further, I noticed this focus shift also interferes with a ComboBox used as an edit component with autoselect=true
such that once the user finally activates the component the filter contents are no longer selected.
Expected outcome
Clicking a Spreadsheet cell with a custom editor should display and focus the editor.
Minimal reproducible example
define a SpreadsheetComponentFactory
subclass and add it to a Spreadsheet component. Implement only getCustomEditorForCell()
and return a simple component, in my case a ComboBox, for all cells or a specific cell.
In the browser, click that cell, and note where the focus ends up after one cell click.
Steps to reproduce
In the browser, click that cell, and note where the focus ends up after one cell click when the cell has a custom edit component.
Environment
Vaadin version(s): 24.4.8 OS: N/A
Browsers
Issue is not browser related