JavaFX ContextMenu doesn't auto-hide

Interacting with child elements of the parent, will get a focus to that parent. So the context menu will not hide when the button in your code is clicked.

Try these two approaches:
1) Manually manage the visibility of context menu, i.e. hide it on button click:

button.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent arg0) {
        contextMenu.hide();
    }
});

2) Use setContextMenu() instead of showing the context menu on mouse press event:

sp.setContextMenu(contextMenu);