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

8291502: Mouse or touch presses on a non-focusable region don't clear the focusVisible flag of the current focus owner #852

Closed
wants to merge 4 commits into from

Conversation

mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Jul 28, 2022

The focusVisible flag is only set on a node when it acquires input focus using a keyboard interaction, and it is cleared by mouse and touch interactions.

It is not necessary for a node to lose input focus in order to lose focusVisible. Currently, clicking on a region of the scene that does not contain a focusable node does not clear the focusVisible flag.

Detecting clicks or touches that should clear focusVisible can be achieved by adding an event filter for MOUSE_PRESSED and TOUCH_PRESSED to the Scene.

There is an additional noteworthy change with this PR:
Adding event filters to Scene causes many tests to fail due to a bug in MouseEventFirer that was identified in 8253769. Previously, mouse events generated by MouseEventFirer skipped a code path that causes test failures due to incorrect coordinates. With the added event filters, the code path for mouse events is slightly different, exposing the incorrect coordinates and causing tests to fail.
This problem can be solved by making the "alternative" MouseEvent generation path the default path.

Note: Since this is a follow-up fix for 8268225, I'm targeting this fix for jfx19.


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-8291502: Mouse or touch presses on a non-focusable region don't clear the focusVisible flag of the current focus owner

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 852

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 28, 2022

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into jfx19 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 Jul 28, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 28, 2022

Webrevs

@kevinrushforth
Copy link
Member

This will need to be very well-tested to ensure that there are no regressions. As part of the review, we will evaluate whether it is a safe enough fix to go into 19.

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jul 28, 2022

@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
Copy link
Collaborator Author

mstr2 commented Aug 1, 2022

In addition to automated testing, I also manually tested this change by building and running SceneBuilder with it.
As far as I can tell, there's no regression in functionality.

The behavior of the feature after this PR is applied mostly resembles how Windows 10/11, Chrome, and Firefox handle visible focus indicators. There are some very minor differences, which can be addressed later (for example, clicking on scroll bars doesn't seem to count as a mouse interaction Windows/Chrome/Firefox, where it does in this iteration of the focusVisible feature).

@kevinrushforth
Copy link
Member

The changes around KeyHandler might seem to be excessive for the scope of this PR.

They do indeed.

I think that moving the focus-related functionality next to the other focus functions in the Scene class is a safe and straightforward change, and it makes it easier to work with the code in the future.

Be that as it may, this sort of refactoring is discouraged, especially in the case of a fix you want to get in late in the release (we have 3 days left before the RDP2 deadline of JavaFX 19). This will cause extra time for the reviewers and could jeopardize getting it into the release. It would have been better to save this change for a future bug fix.

@mstr2
Copy link
Collaborator Author

mstr2 commented Aug 1, 2022

Be that as it may, this sort of refactoring is discouraged, especially in the case of a fix you want to get in late in the release (we have 3 days left before the RDP2 deadline of JavaFX 19). This will cause extra time for the reviewers and could jeopardize getting it into the release. It would have been better to save this change for a future bug fix.

I've reverted most of the changes around KeyHandler.

@kevinrushforth
Copy link
Member

I've reverted most of the changes around KeyHandler.

Thank you. That will make this much easier to review.

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.

This looks good, with a possible follow-up item to clarify the docs. I think it would be worth updating the spec to say that focusVisible is cleared on a MOUSE_PRESSED or TOUCH_PRESSED event (in addition to the other events that can clear it). I recommend doing this in a follow-up bug, so it doesn't derail getting this bug fix in.

Since this would be a doc-only change, it could be done during RDP2 of JavaFX 19 (or even deferred to JavaFX 20, but it seems best to shoot for 19). Either way, it will need a CSR.

@kevinrushforth
Copy link
Member

As a possible additional follow-on bug for the original feature, in a future release, is that navigating using the Windows Narrator's focus traversal keys doesn't set focusVisible. This is independent of this bug (this PR doesn't change that behavior).

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.

Looks good to me.
I have identified potential cleanup that may be required. It can be done as part of JDK-8253769

@@ -60,6 +60,9 @@ public final class MouseEventFirer {
public MouseEventFirer(EventTarget target) {
this.target = target;

// Use the alternative creation path for MouseEvent by default, see JDK-8253769
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the alternative path is made the default then this class needs some cleanup. That can be done as part of JDK-8253769. Request you to add a comment in JBS on JDK-8253769 to clean up the unused portion of MouseEventFirer.java

@openjdk
Copy link

openjdk bot commented Aug 2, 2022

@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:

8291502: Mouse or touch presses on a non-focusable region don't clear the focusVisible flag of the current focus owner

Reviewed-by: kcr, aghaisas

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 1 new commit pushed to the jfx19 branch:

  • 8fa8919: 8291588: Update boot JDK to 18.0.2

Please see this link for an up-to-date comparison between the source branch of this pull request and the jfx19 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 jfx19 branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Aug 2, 2022
@mstr2
Copy link
Collaborator Author

mstr2 commented Aug 2, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Aug 2, 2022

Going to push as commit 5febaca.
Since your change was applied there has been 1 commit pushed to the jfx19 branch:

  • 8fa8919: 8291588: Update boot JDK to 18.0.2

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 2, 2022

@mstr2 Pushed as commit 5febaca.

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

@mstr2 mstr2 deleted the fixes/focusvisible-click branch August 2, 2022 14:36
@mstr2 mstr2 mentioned this pull request Nov 24, 2022
3 tasks
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
3 participants