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

Prevent group expansion arrow from activating group when expanding or collapsing #8785

Merged
merged 10 commits into from
May 22, 2022
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ private void initialize() {
.map(this::createContextMenuForGroup)
.orElse((ContextMenu) null));
row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
if (event.getButton() == MouseButton.SECONDARY || event.getTarget() instanceof StackPane) {
if (event.getTarget() instanceof StackPane) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pattern matching to avoid unnecessary casts

if (event.getTarget() instanceof StackPane pane) {

if (((StackPane) event.getTarget()).getStyleClass().toString().equals("arrow") || ((StackPane) event.getTarget()).getStyleClass().toString().equals("tree-disclosure-node")) {
event.consume();
}
} else if (event.getButton() == MouseButton.SECONDARY) {
// Prevent right-click to select group
event.consume();
}
Expand Down