Enter shortcut breaks Grid edition (V8)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Having an Enter ShortcutListener in a Textfield at the same level than an editable Grid breaks Grid edition.
Steps to reproduce:
1.- Open the grid editor in the first row and change some value
2.- Hit Enter two times, the cursor should be at third row
3.- Press Enter one time more and you will see how the third-row value changes automagically, concretely, the value from the second row is copied to the third.
Code to reproduce:
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
TextField textField = createTextField();
Grid grid = createGrid();
layout.addComponents(textField, grid);
setContent(layout);
}
private TextField createTextField() {
TextField textField = new TextField();
textField.addShortcutListener(new ShortcutListener("", ShortcutAction.KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
}
});
return textField;
}
private Grid createGrid() {
List<Person> people = Arrays.asList(
new Person("Person 1", 1),
new Person("Person 2", 2),
new Person("Person 3", 3),
new Person("Person 4", 4)
);
ListDataProvider<Person> personListDataProvider = DataProvider.ofCollection(new ArrayList<>(people));
Grid grid = new Grid(Person.class);
grid.getColumn("name").setEditorComponent(new TextField());
grid.setDataProvider(personListDataProvider);
grid.setColumns("name");
grid.getEditor().setEnabled(true);
grid.getEditor().setBuffered(false);
return grid;
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Java reproduction from the issue with a TextField ShortcutListener and editable Grid, then inspect the Grid editor and shortcut-handling paths involved in repeated Enter presses. Done means pressing Enter as described no longer copies the second-row value into the third row.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100