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
Remove KeytipData usage from Link, Checkbox, Toggle (react-next) #13742
Conversation
<Toggle onText="Yes" offText="No" keytipData={toggleKeytipData} /> | ||
<span> | ||
Go to{' '} | ||
<Link keytipData={linkKeytipData} href="http://www.bing.com" target="_blank"> |
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.
Before:
<Link keytipProps={keytipMap.LinkKeytip} href="http://www.bing.com" target="_blank">
After:
const linkKeytipData = useKeytipData({ keytipProps: keytipMap.LinkKeytip });
<Link keytipData={linkKeytipData} href="http://www.bing.com" target="_blank">
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.
Instead why not this?
<Keytip {...keytipProps}>
<Link href="..." target="...">...</Link>
</Keytip>
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.
Updated the code:
Before:
<Link keytipProps={keytipMap.LinkKeytip} href="http://www.bing.com" target="_blank">
After:
const linkRef = useKeytipRef({ keytipProps: keytipMap.LinkKeytip });
<Link ref={linkRef} href="http://www.bing.com" target="_blank">
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Asset size changes
Over Tolerance (1024 B) Over Baseline Below Baseline New Removed 1 kB = 1000 B Baseline commit: d43db14983c012854c144263821109e09ed15310 (build) |
change/@fluentui-react-next-2020-06-22-11-18-19-xgao-useKeytipData.json
Outdated
Show resolved
Hide resolved
change/office-ui-fabric-react-2020-06-22-11-18-19-xgao-useKeytipData.json
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/KeytipData/useKeytipData.ts
Outdated
Show resolved
Hide resolved
fe87fa5
to
656b064
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 10d068e:
|
656b064
to
0c74b56
Compare
1ade513
to
2cba581
Compare
@dzearing @khmakoto @kelseyyoung - I updated the code and added The idea is that the hook will return a ref which then user can pass the ref to whichever component keytip is targeting. The ref will allow the hook to access the root element that it's targeting and sets proper keytip attributes based on (optional) data attributes set within the root element. |
@xugao would the ref approach be problematic if the 'ref' attribute for the component was already used? |
@kelseyyoung - user can merge multiple refs into one. we have an implementation in |
* Optional keytip for this Link | ||
* Optional keytip. | ||
* | ||
* @deprecated This no longer works. Use `useKeytipData` hook instead. |
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.
This doesn't seem like the right deprecation message - is there any way to have this value deprecated in v7 with an alternative implementation for customers?
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.
If we can deprecate it (but keep it functional)_ with the viable alternative in v7, and then remove it in v8, that's a better user experience. They can update to wrapping things before the upgrade, right now, in v7.
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.
Unfortunately user can't use the new approach on V7 components, because they don't support passing ref
to the root element
packages/react-next/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap
Show resolved
Hide resolved
64e5189
to
10d068e
Compare
🎉 Handy links: |
Pull request checklist
$ yarn change
Description of changes
Removed
KeytipData
usage from Link, Checkbox, Toggle components:keytipProps
useKeytipRef
hook and pass the ref to the targeted componentHow to apply
Keytip
to a component after this change, here is an example:You can also find usage examples in
Keytips.Basic.Example.tsx
Focus areas to test
(optional)