-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Button: Adding various tests and updating component to include componentRef #13718
Conversation
change/@uifabric-react-hooks-2020-06-19-12-26-25-fix-button-fixes.json
Outdated
Show resolved
Hide resolved
…ix/button-fixes # Conflicts: # packages/react-button/config/tests.js # packages/react-button/jest.config.js # packages/react-button/src/components/Button/Button.test.tsx
…ix/button-fixes # Conflicts: # packages/react-hooks/src/useMergedRefs.ts
change/@fluentui-react-button-2020-06-19-15-32-16-fix-button-fixes.json
Outdated
Show resolved
Hide resolved
…ixes.json Co-authored-by: Makoto Morimoto <Humberto.Morimoto@microsoft.com>
Co-authored-by: Makoto Morimoto <Humberto.Morimoto@microsoft.com>
…ix/button-fixes # Conflicts: # packages/react-button/etc/react-button.api.md # packages/react-button/package.json # packages/react-button/src/components/Button/useButton.ts
…ix/button-fixes # Conflicts: # .codesandbox/ci.json # packages/react-button/etc/react-button.api.md # packages/react-button/package.json # packages/react-button/src/components/Button/ButtonBase.tsx # packages/react-button/src/components/Button/useButton.ts
…ix/button-fixes # Conflicts: # packages/react-button/package.json
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 04bce6d:
|
Asset size changes
Over Tolerance (1024 B) Over Baseline Below Baseline New Removed 1 kB = 1000 B Baseline commit: 7932ae5eef247af9b914e8f05efdaac0b64914f8 (build) |
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Hey folks! Can you please clarify why you have decided to go this approach? As I don't see any benefits from it. Issue 1: Additional APIIt adds an additional API about what customer should know and learn. In the same time there is an existing API with At the same time there is no additional value from it as points to the same element:
Issue 2: Endless storyAs customer I would like to have access to other DOM methods like function App() {
const ref = React.useRef() // Should I use `.focus()` there?
const componentRef = React.useRef() // Or there?
return <Button componentRef={componentRef} ref={ref} />
} Issue 3: Internal usageThere are cases where we will need refs to call some DOM methods like So what we should prefer internally const isComponentRefSupported = !!slots.button.type.IS_FLUENT_COMPONENT
// ??? But we know that this will not work because of HoCs at least |
🎉 Handy links: |
Ah communication gap, so I'll give some thorough explanation here, hopefully this will shed more light on the thinking. If by the end you still feel like this is crazy-sauce, feel free to suggest alternatives on how to provide imperative apis when needed without requiring customers reaching into DOM structure and doing things we may want to change later.
I don't think you're following it quite right. The reasoning for
By having
No, we should not expose every possible API as an abstraction on the DOM. We should prioritize declarative ways to expose functionality. If that doesn't make sense (e.g. an Input's We've found limiting and abstracting common imperative APIs is a good thing:
And yes, now there are multiple ways to do the same thing, which in principle we want to avoid. You could set focus to a Button by calling
Again, open to alternatives if this doesn't make sense. But I don't think "reach into the DOM" is the right answer for every imperative operation and we should try and avoid that either by having declarative ways to do things, or a recommended and supported and reliable way of imperatively doing things. |
What we are going to use internally? You mentioned |
What is a purpose to have this API for |
Let's have a sync on this one. I think we moved a little too fast both in merging this and in objecting to it. Let's take a look at the use cases we have, refresh ourselves on the latest React docs dealing with refs and the DOM (especially exposing DOM refs to parents and forwardRef), and hop on a call to discuss. Who's in? Reminders👉 We discussed this to a decent degree in our last off site as well, notes aren't too telling but here they are:
👉 We also have slots, so you can already get a ref to any part of the component, including the root: const MyComponent = () => {
const rootRef = React.useRef();
const iconRef = React.useRef();
const headerRef = React.useRef();
const descriptionRef = React.useRef();
const actionRef = React.useRef();
const progressRef = React.useRef();
return (
<Attachment
ref={{ ref: rootRef }}
icon={<MyIcon ref={iconRef} />}
header={{ ref: headerRef }}
description={{ ref: descriptionRef }}
action={{ ref: actionRef }}
progress={{ ref: progressRef }}
/>
);
}; |
Setting up componentRef focus method, adding tests.