-
Notifications
You must be signed in to change notification settings - Fork 361
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
feat(focusable): add focusable component #3845
feat(focusable): add focusable component #3845
Conversation
PF3 preview: https://patternfly-react-pr-3845-pf3.surge.sh |
Codecov Report
@@ Coverage Diff @@
## master #3845 +/- ##
==========================================
+ Coverage 60.3% 60.35% +0.05%
==========================================
Files 405 406 +1
Lines 6225 6236 +11
Branches 2306 2313 +7
==========================================
+ Hits 3754 3764 +10
Misses 2042 2042
- Partials 429 430 +1
Continue to review full report at Codecov.
|
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, I like this approach much better. We're not altering the underlying HTML button element and instead relying on standard HTML behavior for the disabled state. And this functionality can be used with just about any component!
However, I see one potential issue. When I remove the isDisabled
prop from button, both the button and container are focusable.
Can we ensure that the example is mutually exclusive? For example, we could add an isDisabled
property to the focusable
component. Then, if the button is enabled, the focusable
component is not.
Alternatively, the focusable
component could test the disabled state of its immediate child. Or, use a component ref
to test the disabled state of a specific child?
Does this need to be experimental / beta?
Probably don't need to update the yarn.lock, right?
eba09ca
to
f92e5d2
Compare
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.
Looking good. Just a nit about the interface prefix.
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 great!
d7d2097
to
5d94289
Compare
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 great! One little nit.
add cypress tests add prop for dynamically controlling focusability/classname
5d94289
to
2e8630f
Compare
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.
LGTM 👍
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.
Could the default div tag use pf-u-display-inline-block
? That way, the focus ring won't extend beyond the underlying button, radio, etc.
<Tooltip content={...}>
<div className="pf-u-display-inline-block">
<Button isDisabled>I have a tooltip!</Button>
</div>
</Tooltip>
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.
LGTM
When I test the examples of Focusable with tooltips in VO, the tooltip contents are not announced. Additionally for the disabled buttons, there are slight differences with how VO behaves depending on navigation method. Using the tab key, VO announces the element as a group instead of a button. It does add "you are currently on a button," but the semantics in this case are slightly different. For example, the disabled button is announced as:
Using the next element navigation or navigating by form control, the element is announced as a button and the button is announced as disabled.
Assuming the issue with the tooltip getting announced is fixed, there are still a couple of concerns I have with this method:
I still favor the original implementation of adding the prop directly on the element to state that it's disabled but focusable. It avoids the issues mentioned above, since we're not adding addltional wrapping elements that alter the semantics of the normal state of the element. It also seemed like a much cleaner solution, both in implementation, but also when using it (as a consumer, I should be able to just add a prop to say that something is disabled). |
I'm not sure if you would need to import the entire display utility CSS (which is 3.7k) but an alternative could be to use a This looks pretty cool! My main concern is supporting layouts that depend on a I included in there an example of Side note, this may be something that is resolved in later implementations of |
Thanks for the feedback! Wanted to address a couple of things while we collect more comments/feedback.
I noticed they are not announced when focusing with VO cursor (reader focus), however if you tab onto the element with the standard tab key, the tooltip content does get announced - however, it's announced later after the reader has finished reading other contextual aspects of the current view. So (for this implementation strategy) I don't think it's as much a matter of getting the announcements "fixed" as it is just realizing when we should and shouldn't expect the announcements to take place. Seems like descriptions/tooltips are generally only announced on TAB focus, not screen reader focus. I think exploring the impact/differences of screen reader focus vs keybaord focus is in play here, and adjusting our expectations around how these things should function can make the path forward a little more clear and flexible. I'm starting to see how both implementations we're comparing here can be useful as tools in the toolset to build accessible experiences, and maybe there's less value in forcing to pick one as the "correct" path forward. IMO the need here is becoming more about offering tools to enable developers to build good AX rather than doing it for them or constructing tools in such a way that "prevents" them from composing solutions in a way that may be inaccessible.
Yes would need to import the display utilities, the size difference I think is nominal though. Using a |
What: This PR adds a new
Focusable
component that can be used to wrap other elements/components to make them focusable. I haven't had a chance to add cypress tests yet, but wanted to go ahead and get the work up for review in case people have time to take a look and provide feedback.Closes #3791
It also serves as an alternative approach to #3817
Additional issues: Steps toward closing #1894