Skip to content

Commit

Permalink
feat(auto-complete): add forwardRef for input element (#542)
Browse files Browse the repository at this point in the history
* feat(auto-complete): add forwardRef for input element

* test(auto-complete): add testcase to ensure ref is available

* docs(auto-complete): append props for ref
  • Loading branch information
unix authored May 24, 2021
1 parent a9bd28e commit 622de49
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AutoComplete should render correctly 1`] = `
<AutoComplete
<ForwardRef
className=""
clearable={false}
disableFreeSolo={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ initialize {
"children": Array [
Node {
"data": "
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
"next": null,
"parent": [Circular],
"prev": null,
Expand Down Expand Up @@ -410,16 +410,16 @@ initialize {
"children": Array [
Node {
"data": "
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
"next": null,
"parent": [Circular],
"prev": null,
Expand Down Expand Up @@ -1205,16 +1205,16 @@ initialize {
"children": Array [
Node {
"data": "
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
"next": null,
"parent": [Circular],
"prev": null,
Expand Down Expand Up @@ -1245,16 +1245,16 @@ initialize {
"children": Array [
Node {
"data": "
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
.auto-complete {
width: max-content;
}
.auto-complete :global(.loading) {
left: -3px;
right: -3px;
width: max-content;
}
",
"next": null,
"parent": [Circular],
"prev": null,
Expand Down
7 changes: 7 additions & 0 deletions components/auto-complete/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ describe('AutoComplete', () => {

expect(wrapper.prop('width')).toEqual('200px')
})

it('should forward ref by default', () => {
const ref = React.createRef<HTMLInputElement>()
const wrapper = mount(<AutoComplete ref={ref} />)
expect(ref.current).not.toBeNull()
expect(() => wrapper.unmount()).not.toThrow()
})
})
Loading

0 comments on commit 622de49

Please sign in to comment.