Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

feat(useAccessibility): add support for FocusZone #2275

Merged
merged 3 commits into from
Jan 27, 2020
Merged

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jan 27, 2020

This PR adds an experimental support for FocusZone to the useAccessibility 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.

@@ -38,9 +38,7 @@ export interface IFocusZone {
/**
* FocusZone component props.
*/
export interface FocusZoneProps
extends FocusZoneProperties,
React.HTMLAttributes<HTMLElement | FocusZone> {
Copy link
Member Author

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') {
Copy link
Member Author

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

@DustyTheBot
Copy link
Collaborator

DustyTheBot commented Jan 27, 2020

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Perf comparison

Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🔧 Avatar.Fluent 0.57 0.38 1.5:1 2000 1145
🔧 Button.Fluent 1.26 0.18 7:1 1000 1264
🔧 Checkbox.Fluent 1.36 0.29 4.69:1 1000 1358
🔧 Dialog.Fluent 0.33 0.16 2.06:1 5000 1643
🔧 Dropdown.Fluent 3.42 0.38 9:1 1000 3415
🔧 Icon.Fluent 0.24 0.03 8:1 5000 1189
🔧 Image.Fluent 0.11 0.07 1.57:1 5000 535
🔧 Slider.Fluent 1.84 0.29 6.34:1 1000 1835
🦄 Text.Fluent 0.05 0.16 0.31:1 5000 250
🦄 Tooltip.Fluent 0.37 17.66 0.02:1 5000 1834

🔧 Needs work     🎯 On target     🦄 Amazing

Generated by 🚫 dangerJS

mergeProps(slotName, slotProps, definition)

// Provides an experimental handling for FocusZone definition in behaviors
getA11Props.unstable_withFocusZone = (children: React.ReactElement) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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.

Copy link
Contributor

@mnajdova mnajdova left a 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..

@layershifter layershifter merged commit 35da256 into master Jan 27, 2020
@layershifter layershifter deleted the feat/use-acc-fz branch January 27, 2020 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants