-
Notifications
You must be signed in to change notification settings - Fork 5k
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
forwarding refs to Box and Text component #16062
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
@@ -29,61 +29,72 @@ export const ValidTags = [ | |||
'strong', | |||
'ul', | |||
'label', | |||
'input', |
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.
We are using the Text component and polymorphic prop to create the input element in TextInputBase component PR https://github.com/MetaMask/metamask-extension/pull/16043/files#diff-d3b7305f6fb5c8d3d68007b90b8edefae588ed1141b5319e3785c4bc4f03c218R138-R167
const mockRef = jest.fn(); | ||
render(<Text ref={mockRef} />); | ||
expect(mockRef).toHaveBeenCalledTimes(1); | ||
}); |
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.
I don't think this is the most robust test but I struggled to find a reliable way to unit test forwarding refs open to suggestions
Explanation
Currently, the Box component does not forward refs down to it's root html element
This is a problem because we use the Box component as a base for all of our UI components. It's handy to be able to pass refs to components such as inputs or you need a DOM node's dimensions
In order to solve this problem, this pull request forwards refs for the Box and Text component.
More Information
Part of Adding
TextFieldBase
component #16043Pre-Merge Checklist
[ ] PR has been added to the appropriate release MilestoneN/A+ If there are functional changes:
[ ] "Extension QA Board" label has been appliedN/A