-
Notifications
You must be signed in to change notification settings - Fork 53
feat(useAccessibility): add support for FocusZone #2275
Conversation
@@ -38,9 +38,7 @@ export interface IFocusZone { | |||
/** | |||
* FocusZone component props. | |||
*/ | |||
export interface FocusZoneProps | |||
extends FocusZoneProperties, | |||
React.HTMLAttributes<HTMLElement | FocusZone> { |
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.
React.HTMLAttributes<HTMLElement | FocusZone>
is really strange and looks broken.
It also creates collisions with other typings as HTMLAttributes
includes callbacks like onClick
and if FocusZone
is included it creates onClick: (e: FocusZone)
💣
if (definition.focusZone) { | ||
let element: React.ReactElement = children | ||
|
||
if (process.env.NODE_ENV !== 'production') { |
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.
It's already restricted by typings, but it will be also good to have a runtime checks
Perf comparison
Generated by 🚫 dangerJS |
mergeProps(slotName, slotProps, definition) | ||
|
||
// Provides an experimental handling for FocusZone definition in behaviors | ||
getA11Props.unstable_withFocusZone = (children: React.ReactElement) => { |
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.
Would suggest renaming to unstable_wrapwithFocusZone
mergeProps(slotName, slotProps, definition) | ||
|
||
// Provides an experimental handling for FocusZone definition in behaviors | ||
getA11Props.unstable_withFocusZone = (children: React.ReactElement) => { |
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.
It's a bit confusing in this context, what is children and what is element... Let's simplify it a bit.
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.
Not sure about the API at all, but let's unblock our self and iterate on it. It is unstable at this moment, so people should not use it anyway..
This PR adds an experimental support for
FocusZone
to theuseAccessibility
hook as FocusZone behavior can be described in accessibility behaviors.No changelog entries as this feature is an experimental. To be sure that this API is good we need to do more components, however there should be a way to use
FocusZone
right now and it allows to avoid breaking changes until we will be sure.