-
Notifications
You must be signed in to change notification settings - Fork 541
8268225: Support :focus-visible and :focus-within CSS pseudoclasses #475
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
Conversation
|
👋 Welcome back mstr2! A progress list of the required criteria for merging this PR into |
|
Do you have a example application or something, where the possible use case/the advantage of this can be shown? I can't imagine right now, where I may want to use that. |
If you are running Windows 10, try opening PC Settings, then go to a section like System > Notifications and actions. There are lots of switches and check boxes that you can toggle, but you'll notice that they don't have any visible focus indicator if you click on them (even tough they are focused after clicking). Only if you press the Tab key you'll see a black border as a visual focus indicator, which will disappear again after clicking. |
Webrevs
|
|
I note that the discussion hasn't finished on the openjfx-dev mailing list as to whether to accept this feature. The proposed API and docs in this PR can be used to inform the discussion, but it's premature to start the code review. If it ends up going forward, it will need a CSR and 2 reviewers. /csr |
|
@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
|
@kevinrushforth |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took an initial pass at the API docs. I have a couple global comments.
First, can you reorder the properties and their associated methods such that they are grouped together? If the docs are on the (private) field, which is what we usually do, it should be followed immediately by the associated setter (if any), getter, and property methods.
The order should be:
/**
* EXISTING API DOCS FOR FOCUSED PROPERTY
*/
private FocusPropertyBase focused;
protected final void setFocused(boolean value) {
public final boolean isFocused() {
public final ReadOnlyBooleanProperty focusedProperty() {
/**
* API DOCS FOR NEW FOCUSVISIBLE PROPERTY
*/
private FocusPropertyBase focusVisible;
public final boolean isFocusVisible() {
public final ReadOnlyBooleanProperty focusVisibleProperty() {
...
Second, the two new properties need both a @defaultValue and an @since NN tag. You can optimistically use @since 17 or you can use @since 18 (the latter is more likely).
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks reasonable. I left one question inline.
The implementation will take some time to go through. I doubt that this will make JavaFX 17 (which I alluded to earlier). I'm especially curious about some of the patterns that I see, mostly surrounding the FocusPropertyBase implementation class.
FocusPropertyBaseoverridesset(which is unusual). The current implementation (ofFocusedProperty) has some custom logic as well, but it didn't try to use the set method of a writable property. Also, you use a writable property and don't overrideinvalidated. Can you say why you made the changes you made?- I'm curious about the approach for notifying listeners. It seems similar to what is currently done for
focusedProperty, but there are differences. Also, I'm not sure that the two newly added properties need to handle notifications in the same way as focused. I can think of at least one potential issue. If focus shifts from one node to another in the same parent, you might end up notifying a parent's listeners even though itsfocusWithinis unchanged. - I think the way you are propagating
focusWithinmight not work if nodes are added or removed from the scene graph. - Normally a read-only property that needs to be settable by the implementation would use
ReadOnlyBooleanWrapper. And then the public property method would callgetReadOnlyPropertyto return the read-only property to the user. The implementation would access the wrapper and you don't need to cast. You could consider havingFocusPropertyBaseextendReadOnlyBooleanWrapper.
One thing to consider would be to keep the existing (internal) class for focused and use a more standard ReadOnlyBooleanWrapper class for the two new ones. But maybe there are some implications I haven't thought of yet.
Technically, it doesn't override
There's a test for this scenario:
Good point, I'll try to come up with some test cases to see if there are any issues.
That could certainly be an option, although it would increase the memory footprint of I think that having the same deferred-notification property implementation for all three focus-related properties is the best approach, since the implementation guarantees that listeners are only notified after all changes are committed. At least, I see no upside to not guarantee this. Maybe the atomicity guarantee for |
|
@kevinrushforth Do you think this could be a candidate for 19? |
|
I'd like to try to get this in for 19, although time is short. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks good. I also reviewed the implementation, and it seems fine. I left a few comments inline.
If you still want to get this into JavaFX 19, can you update the CSR as follows?
- Change the
@sincetags from 18 to 19 - For the two new properties, please add the two public methods for each property, replacing the "private" field (if you prefer, you can leave the private field as well).
- The diffs for
cssref.htmlneed to be added to the Specification section.
Once you do that, I will "Review" the CSR, since I am done reviewing the API changes in this PR. You can then Finalize it.
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ButtonBehavior.java
Show resolved
Hide resolved
|
One more comment: Have you addressed all questions from @kleopatra ? |
|
I've updated the CSR as requested.
The question was about a parent that is inserted above a focused node in the scene graph. Currently, a focused node remains the focus owner of the scene, even if it is removed from the scene graph in this way. Independent of whether that's a bug, I don't think that question is relevant for this particular PR. We might create a follow-up ticket to investigate the issue and determine whether it's a bug or not. |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I just Reviewed it, so go ahead and Finalize it.
I agree.
Yes, this sounds like a bug. A follow-up issue seems in order. |
|
I've finalized the CSR. |
aghaisas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this has baked well.
I have a very minor comment for a missing javadoc tag.
...afx.controls/src/main/java/com/sun/javafx/scene/control/behavior/FocusTraversalInputMap.java
Show resolved
Hide resolved
|
@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: 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 22 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @aghaisas) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
/sponsor |
|
Going to push as commit 8d5d3ca.
Your commit was automatically rebased without conflicts. |
|
@kevinrushforth @mstr2 Pushed as commit 8d5d3ca. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR adds the
Node.focusVisibleandNode.focusWithinproperties, as well as the corresponding:focus-visibleand:focus-withinCSS pseudo-classes.Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/475/head:pull/475$ git checkout pull/475Update a local copy of the PR:
$ git checkout pull/475$ git pull https://git.openjdk.org/jfx pull/475/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 475View PR using the GUI difftool:
$ git pr show -t 475Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/475.diff