Delete button on grid causes NullPointerException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
I have a grid configured with button renderer. Button deletes its own element row from the grid. When user attempts to delete multiple rows by clicking on delete button fast, grid produces NullPointerException: "editor can't edit null".
This is because vaadin on client side decides second click is actually double click on just removed row and attempts to open editor.
Similar issue was reported here: https://vaadin.com/forum/thread/16616603/vaadin-8-buttonrenderer-doubleclick
Workaround - create custom grid:
@SuppressWarnings({ "javadoc", "serial" })
public class CustomGrid<T> extends Grid<T> {
@Override
protected Editor<T> createEditor() {
return new FixedEditorImpl<>(getPropertySet());
}
}
@SuppressWarnings("serial")
class FixedEditorImpl<T> extends EditorImpl<T> {
public FixedEditorImpl(PropertySet<T> propertySet) {
super(propertySet);
}
@Override
protected void doEdit(T bean) {
if (bean == null) {
cancel();
return;
}
super.doEdit(bean);
}
}
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 with Vaadin Grid's button renderer and editor path, especially Grid#createEditor and EditorImpl#doEdit, using the reproduction described in the issue. Done means rapidly deleting multiple rows no longer treats the second click as a double-click on the removed row or raises "editor can't edit null".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100