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

Conversation

LIM0000
Copy link
Contributor

@LIM0000 LIM0000 commented May 11, 2022

Previous discussion for group activation when expanding or collapsing group #7982

When I want to assign an entry to a subgroup, I have to first expand the parent group and then drag-and-drop my entry in the appropriate subgroup. The problem is that when I expand the group, by clicking on the arrow on the right, the group gets activated (the entry table only shows the group entries) and, therefore, I have to go back to "All entries" and locate my entry again. The parent group gets activated when collapsing it as well.

Proposal solution: Prevent group activation/select when user clicks on group expanding or collapsing arrow

Fixes: #7982
Fixes #3176

if (event.getButton() == MouseButton.SECONDARY || event.getTarget() instanceof StackPane) {
          // Prevent right-click to select group
          event.consume();
}
1.1.mp4

Further discussion

It might not be a good idea to only check eventTarget that returns StackPane class, as the group expand arrow is the only column that is using the StackPane class at current JabRef version. Any feedbacks are much appreciated!

PR Checklist:

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@ThiloteE
Copy link
Member

ThiloteE commented May 11, 2022

Fixes #7982
Fixes #3176

@LIM0000 did you know about this? :-)

Edit: Sorry, did not see you already linked. Ups, my fault. Wanted to link 3176 too though :)

@calixtus
Copy link
Member

I like the basic idea, I'm just thinking if "instanceof StackPane" is determined enough to prevent other side effects (e.g. the hits badge is a StackPane too)
Maybe you can test on the styleclass "tree-disclosure-node" as well?

@LIM0000
Copy link
Contributor Author

LIM0000 commented May 17, 2022

Thank you for your review @calixtus.

I agree that just instanceof StackPane is not determined enough. I have fixed this issue in the latest commit by confirming if the targeted StackPane has either arrow or tree-disclosure-node style class.

The reason that tree-disclosure-node included is because StackPane arrow style class has a very small clickable area. It will be very tedious to click directly onto the arrow icon and prevent activating group.

Clickable area if only include arrow
111

Clickable area (red) if include both area and tree-disclosure-node
222

@@ -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) {

@@ -269,6 +269,10 @@ private void initialize() {
if (event.getButton() == MouseButton.SECONDARY) {
// Prevent right-click to select group
event.consume();
} else if (event.getTarget() instanceof StackPane pane) {
if (pane.getStyleClass().toString().equals("arrow") || pane.getStyleClass().toString().equals("tree-disclosure-node")) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's better to check for contains, because there could also be multiple style classes assigned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @calixtus , it has been updated with contains().
Really appreciate your review!

@LIM0000 LIM0000 marked this pull request as ready for review May 19, 2022 23:25
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label May 22, 2022
@Siedlerchr
Copy link
Member

LGTM! Is this fix also for #3176 ?

@LIM0000
Copy link
Contributor Author

LIM0000 commented May 22, 2022

Hi @Siedlerchr , I believe that #3176 has also been fixed based on #7982 (comment) and #7982 (comment).
I have updated CHANGELOG.md file that stated fixes for #7982 and #3176.
Cheers.

@Siedlerchr Siedlerchr merged commit a355534 into JabRef:main May 22, 2022
@Siedlerchr
Copy link
Member

Thanks again for your contributions! Superb so far! We really appreciate your engagement

@credmond
Copy link
Contributor

Hey @Siedlerchr @LIM0000

This fix/improvement has been reversed/broken by this commit:

bc662cb

...because the event is being intercepted and consumed, now via an EventHandler (bubbling phase) rather than capture phase, as was previous. So it's too late, the node has already been selected as before.

E.g., row.addEventFilter(MouseEvent.MOUSE_PRESSED ...) is gone with the re-factor in the above link.

@Siedlerchr
Copy link
Member

Siedlerchr commented Jul 24, 2023 via email

credmond added a commit to credmond/jabref that referenced this pull request Jul 24, 2023
…nt: JabRef#8785. Now, once again, the mouse click is handled and consumed at the capture stage if the expansion pane is licked, therefore preventing the node from being selected.
credmond added a commit to credmond/jabref that referenced this pull request Jul 24, 2023
…nt: JabRef#8785. Now, once again, the mouse click is handled and consumed at the capture stage if the expansion pane is licked, therefore preventing the node from being selected.
@credmond
Copy link
Contributor

@Siedlerchr, done: #10111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
groups status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't activate group when expanding or collapsing Unexpected behaviour: Groups search - Item assignment
5 participants