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

8300013: Node.focusWithin doesn't account for nested focused nodes #993

Closed
wants to merge 3 commits into from

Conversation

mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Jan 12, 2023

When a scene graph contains multiple nested focused nodes (this can happen with TableView and other controls), the focusWithin bits that are cleared when a focused node is de-focused must only be cleared when there is no other nested node in the scene graph that would also cause focusWithin to be set.

For example, consider a scene graph of nested nodes:
A -> B -> C -> D

When B and D are both focused, the scene graph looks like this:
A(focusWithin)
-> B(focused, focusWithin)
-> C(focusWithin)
-> D(focused, focusWithin)

When B is de-focused, the focusWithin flags must still be preserved because D remains focused.

This PR fixes the issue by counting the number of times focusWithin has been "set", and only clears it when it has been "un-set" an equal number of times.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8300013: Node.focusWithin doesn't account for nested focused nodes

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/993/head:pull/993
$ git checkout pull/993

Update a local copy of the PR:
$ git checkout pull/993
$ git pull https://git.openjdk.org/jfx pull/993/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 993

View PR using the GUI difftool:
$ git pr show -t 993

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/993.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 12, 2023

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Jan 12, 2023
@mstr2
Copy link
Collaborator Author

mstr2 commented Jan 12, 2023

I think this should go into JavaFX 20.

@mlbridge
Copy link

mlbridge bot commented Jan 12, 2023

Webrevs

@kevinrushforth
Copy link
Member

I think this should go into JavaFX 20.

I agree. In the (very likely) case it doesn't get reviewed before the fork, I'll ask you to retarget it to the jfx20 branch.

@kevinrushforth
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jan 12, 2023

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@mstr2 mstr2 changed the base branch from master to jfx20 January 12, 2023 16:33
@tcfurrer
Copy link

tcfurrer commented Jan 16, 2023

Hi @tcfurrer, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user tcfurrer for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

Copy link
Collaborator

@aghaisas aghaisas left a comment

Choose a reason for hiding this comment

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

The fix looks fine to me!

@mstr2
Copy link
Collaborator Author

mstr2 commented Jan 26, 2023

@kevinrushforth @arapte With RDP1 ending soon, would you be willing to review this fix?

@kevinrushforth
Copy link
Member

@kevinrushforth @arapte With RDP1 ending soon, would you be willing to review this fix?

One of us will review it next week.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Looks good. Approved for jfx20.

I left a couple questions, one of which might warrant a follow-up issue depending on your answer.

void adjust(int change) {
count += change;

if (count == 1) {
Copy link
Member

Choose a reason for hiding this comment

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

This presumes that you never call this with change > 1. You don't, so it seems fine.

set(true);
} else if (count == 0) {
set(false);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth adding a check for count < 0 and logging a warning (possibly treating it as if it were 0)? In theory, it shouldn't happen, but if it ever did, focusWithin would be wrong after that. This could be done as a P4 follow-up for 21, unless you are certain that it cannot ever happen.

Copy link
Collaborator Author

@mstr2 mstr2 Jan 31, 2023

Choose a reason for hiding this comment

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

On the one hand, this might make the code a little bit more robust, but on the other hand, it might hide a bug elsewhere. Surely count should never be negative. I lean slightly towards not protecting code against bugs in this way, mostly because it might expose potential bugs sooner.

If we want to validate that this method is not called with an incorrect argument, maybe just throwing an exception would be better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've created a ticket to investigate this: https://bugs.openjdk.org/browse/JDK-8301556

@openjdk
Copy link

openjdk bot commented Jan 31, 2023

@mstr2 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8300013: Node.focusWithin doesn't account for nested focused nodes

Reviewed-by: aghaisas, kcr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 24 new commits pushed to the jfx20 branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the jfx20 branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Jan 31, 2023
@mstr2
Copy link
Collaborator Author

mstr2 commented Jan 31, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jan 31, 2023

Going to push as commit a4bc9d1.
Since your change was applied there have been 24 commits pushed to the jfx20 branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 31, 2023
@openjdk openjdk bot closed this Jan 31, 2023
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Jan 31, 2023
@openjdk
Copy link

openjdk bot commented Jan 31, 2023

@mstr2 Pushed as commit a4bc9d1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mstr2 mstr2 deleted the fixes/JDK-8300013 branch April 8, 2023 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
4 participants