Skip to content

Commit de230ad

Browse files
kinkejukben
authored andcommitted
Fix TextArea DOM ref when specifying textAreaComponent (#133)
* Fix TextArea DOM ref when specifying textAreaComponent * Added Kinke into contributors
1 parent 508636a commit de230ad

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@
193193
"bug",
194194
"code"
195195
]
196+
},
197+
{
198+
"login": "kinke",
199+
"name": "Martin Kinkelin",
200+
"avatar_url": "https://avatars0.githubusercontent.com/u/1889215?v=4",
201+
"profile": "https://github.com/kinke",
202+
"contributions": [
203+
"bug",
204+
"code"
205+
]
196206
}
197207
],
198208
"repoType": "github"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Enhanced textarea to achieve autocomplete functionality.
55

66
[![MIT License][license-badge]][license]
77
[![PRs Welcome][prs-badge]](#Development)
8-
[![All Contributors](https://img.shields.io/badge/all_contributors-19-orange.svg?style=flat-square)](#contributors)
8+
[![All Contributors](https://img.shields.io/badge/all_contributors-20-orange.svg?style=flat-square)](#contributors)
99
[![npm](https://img.shields.io/npm/dw/@webscopeio/react-textarea-autocomplete.svg?style=flat-square)](https://www.npmjs.com/package/@webscopeio/react-textarea-autocomplete)
1010

1111
<hr>
@@ -267,7 +267,7 @@ Also, I'd love to thank these wonderful people for their contribution ([emoji ke
267267
| [<img src="https://avatars3.githubusercontent.com/u/8135252?v=4" width="100px;"/><br /><sub><b>Jakub Beneš</b></sub>](https://jukben.cz)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=jukben "Code") [📖](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=jukben "Documentation") [🎨](#design-jukben "Design") [🤔](#ideas-jukben "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/3114719?v=4" width="100px;"/><br /><sub><b>Andrey Taktaev</b></sub>](https://github.com/JokerNN)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=JokerNN "Code") | [<img src="https://avatars0.githubusercontent.com/u/10706203?v=4" width="100px;"/><br /><sub><b>Marcin Lichwała</b></sub>](https://github.com/marcinlichwala)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=marcinlichwala "Code") [📖](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=marcinlichwala "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/9276511?v=4" width="100px;"/><br /><sub><b>Davidson Nascimento</b></sub>](https://github.com/davidsonsns)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=davidsonsns "Code") | [<img src="https://avatars1.githubusercontent.com/u/7477359?v=4" width="100px;"/><br /><sub><b>KajMagnus</b></sub>](http://www.effectivediscussions.org/)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Akajmagnus "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=kajmagnus "Code") | [<img src="https://avatars2.githubusercontent.com/u/1083817?v=4" width="100px;"/><br /><sub><b>Ján Vorčák</b></sub>](https://twitter.com/janvorcak)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Ajvorcak "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=jvorcak "Code") | [<img src="https://avatars2.githubusercontent.com/u/9800850?v=4" width="100px;"/><br /><sub><b>Mateusz Burzyński</b></sub>](https://github.com/Andarist)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=Andarist "Code") [📦](#platform-Andarist "Packaging/porting to new platform") |
268268
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
269269
| [<img src="https://avatars0.githubusercontent.com/u/35139777?v=4" width="100px;"/><br /><sub><b>Deepak Pai</b></sub>](https://github.com/debugpai2)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Adebugpai2 "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=debugpai2 "Code") | [<img src="https://avatars0.githubusercontent.com/u/2336595?v=4" width="100px;"/><br /><sub><b>Aleck Landgraf</b></sub>](http://aleck.me)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=alecklandgraf "Code") | [<img src="https://avatars3.githubusercontent.com/u/8123356?v=4" width="100px;"/><br /><sub><b>Serguei Okladnikov</b></sub>](https://github.com/oklas)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Aoklas "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=oklas "Code") | [<img src="https://avatars1.githubusercontent.com/u/2987177?v=4" width="100px;"/><br /><sub><b>Michal Zochowski</b></sub>](https://github.com/michauzo)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Amichauzo "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=michauzo "Code") | [<img src="https://avatars2.githubusercontent.com/u/1263650?v=4" width="100px;"/><br /><sub><b>Igor Sachivka</b></sub>](https://github.com/isachivka)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Aisachivka "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=isachivka "Code") | [<img src="https://avatars3.githubusercontent.com/u/13059204?v=4" width="100px;"/><br /><sub><b>Andrew Shini</b></sub>](https://github.com/superandrew213)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Asuperandrew213 "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=superandrew213 "Code") | [<img src="https://avatars3.githubusercontent.com/u/3250906?v=4" width="100px;"/><br /><sub><b>Rikesh Ramlochund</b></sub>](https://paperboat.io)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Arrikesh "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=rrikesh "Code") |
270-
| [<img src="https://avatars1.githubusercontent.com/u/983876?v=4" width="100px;"/><br /><sub><b>Matthew Hamilton</b></sub>](https://github.com/diogeneshamilton)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Adiogeneshamilton "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/12836237?v=4" width="100px;"/><br /><sub><b>Danila</b></sub>](https://github.com/O4epegb)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3AO4epegb "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=O4epegb "Code") | [<img src="https://avatars3.githubusercontent.com/u/600021?v=4" width="100px;"/><br /><sub><b>Silvio Di Stefano</b></sub>](http://sites.google.com/site/sdistefano/)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=sdistefano "Code") | [<img src="https://avatars2.githubusercontent.com/u/1162278?v=4" width="100px;"/><br /><sub><b>Jelte Fennema</b></sub>](https://github.com/JelteF)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3AJelteF "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=JelteF "Code") | [<img src="https://avatars0.githubusercontent.com/u/857?v=4" width="100px;"/><br /><sub><b>Andy Pearson</b></sub>](http://andypearson.co)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Aandypearson "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=andypearson "Code") |
270+
| [<img src="https://avatars1.githubusercontent.com/u/983876?v=4" width="100px;"/><br /><sub><b>Matthew Hamilton</b></sub>](https://github.com/diogeneshamilton)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Adiogeneshamilton "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/12836237?v=4" width="100px;"/><br /><sub><b>Danila</b></sub>](https://github.com/O4epegb)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3AO4epegb "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=O4epegb "Code") | [<img src="https://avatars3.githubusercontent.com/u/600021?v=4" width="100px;"/><br /><sub><b>Silvio Di Stefano</b></sub>](http://sites.google.com/site/sdistefano/)<br />[💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=sdistefano "Code") | [<img src="https://avatars2.githubusercontent.com/u/1162278?v=4" width="100px;"/><br /><sub><b>Jelte Fennema</b></sub>](https://github.com/JelteF)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3AJelteF "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=JelteF "Code") | [<img src="https://avatars0.githubusercontent.com/u/857?v=4" width="100px;"/><br /><sub><b>Andy Pearson</b></sub>](http://andypearson.co)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Aandypearson "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=andypearson "Code") | [<img src="https://avatars0.githubusercontent.com/u/1889215?v=4" width="100px;"/><br /><sub><b>Martin Kinkelin</b></sub>](https://github.com/kinke)<br />[🐛](https://github.com/webscopeio/react-textarea-autocomplete/issues?q=author%3Akinke "Bug reports") [💻](https://github.com/webscopeio/react-textarea-autocomplete/commits?author=kinke "Code") |
271271
<!-- ALL-CONTRIBUTORS-LIST:END -->
272272

273273
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

src/Textarea.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,12 @@ class ReactTextareaAutocomplete extends React.Component<
878878
return !!((dataLoading || suggestionData) && currentTrigger);
879879
};
880880

881+
_textareaRef = (ref: HTMLInputElement) => {
882+
// $FlowFixMe - ref is actually a `?HTMLTextAreaElement`
883+
this.props.innerRef && this.props.innerRef(ref);
884+
this.textareaRef = ref;
885+
};
886+
881887
props: TextareaProps;
882888

883889
textareaRef: HTMLInputElement;
@@ -929,11 +935,10 @@ class ReactTextareaAutocomplete extends React.Component<
929935
let TextAreaComponent;
930936
if (textAreaComponent.component) {
931937
TextAreaComponent = textAreaComponent.component;
932-
extraAttrs[textAreaComponent.ref] = x => {
933-
this.textareaRef = x;
934-
};
938+
extraAttrs[textAreaComponent.ref] = this._textareaRef;
935939
} else {
936940
TextAreaComponent = textAreaComponent;
941+
extraAttrs.ref = this._textareaRef;
937942
}
938943

939944
return (
@@ -945,10 +950,6 @@ class ReactTextareaAutocomplete extends React.Component<
945950
>
946951
<TextAreaComponent
947952
{...this._cleanUpProps()}
948-
ref={ref => {
949-
this.props.innerRef && this.props.innerRef(ref);
950-
this.textareaRef = ref;
951-
}}
952953
className={`rta__textarea ${className || ""}`}
953954
onChange={this._changeHandler}
954955
onSelect={this._selectHandler}

0 commit comments

Comments
 (0)