Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialTree: NullPointerException when deselectSelectedItem execute #378

Closed
xkazama-yukio3 opened this issue Feb 4, 2019 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@xkazama-yukio3
Copy link

I use MaterialTree.

I thought that I wanted to manually cancel selected state in MaterialTree,
I attempted to use MaterialTree#deselectSelectedItem() (added from #163)
When execute, NullPointer has occurred.

Reason:
By SelectionEvent (selectedItem = null) fired in the deselectSelectedItem method,
it occurs in SelectionHandler that is set by MaterialTree itself.

Need a null check in SelectionHandler?

for (Widget item : getChildren()) {
    if (item instanceof MaterialTreeItem) {
        clearSelectedStyles((MaterialTreeItem) item);
    }
}
MaterialTreeItem treeItem = event.getSelectedItem();
// Add Check whether tree has selected item
if (treeItem != null) {
	treeItem.addStyleName(AddinsCssName.SELECTED);
}
setSelectedItem(treeItem);
@kevzlou7979
Copy link
Contributor

You are right, this will also trigger a nullpointerexception. Thanks for the catch will be patching this out.

@kevzlou7979
Copy link
Contributor

Fixed via 6f585ff

@kevzlou7979 kevzlou7979 added this to the 2.2 milestone May 8, 2019
@kevzlou7979 kevzlou7979 self-assigned this May 8, 2019
@kevzlou7979 kevzlou7979 added the bug label May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants