summaryrefslogtreecommitdiffstats
path: root/webapp/components/suggestion/suggestion.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-31 16:14:28 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-31 16:14:28 -0400
commit12f659372786c9b9dd3261b4663a4e840da64372 (patch)
treeed7b3234df9ef277fa79759ced5897cc59e83049 /webapp/components/suggestion/suggestion.jsx
parent6e6257fccaa0c5837101dedbe7f547bc3cc6c6bb (diff)
downloadchat-12f659372786c9b9dd3261b4663a4e840da64372.tar.gz
chat-12f659372786c9b9dd3261b4663a4e840da64372.tar.bz2
chat-12f659372786c9b9dd3261b4663a4e840da64372.zip
PLT-2643 Fixed asynchronous autocomplete incorrectly replacing text (#3167)
* Allowed different suggestions to match different text. Added a Suggestion base component. Improved text replacement used when filling in suggestions * Fixed formatting
Diffstat (limited to 'webapp/components/suggestion/suggestion.jsx')
-rw-r--r--webapp/components/suggestion/suggestion.jsx28
1 files changed, 28 insertions, 0 deletions
diff --git a/webapp/components/suggestion/suggestion.jsx b/webapp/components/suggestion/suggestion.jsx
new file mode 100644
index 000000000..8547d50d0
--- /dev/null
+++ b/webapp/components/suggestion/suggestion.jsx
@@ -0,0 +1,28 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import React from 'react';
+
+export default class Suggestion extends React.Component {
+ static get propTypes() {
+ return {
+ item: React.PropTypes.object.isRequired,
+ term: React.PropTypes.string.isRequired,
+ matchedPretext: React.PropTypes.string.isRequired,
+ isSelection: React.PropTypes.bool,
+ onClick: React.PropTypes.func
+ };
+ }
+
+ constructor(props) {
+ super(props);
+
+ this.handleClick = this.handleClick.bind(this);
+ }
+
+ handleClick(e) {
+ e.preventDefault();
+
+ this.props.onClick(this.props.term, this.props.matchedPretext);
+ }
+} \ No newline at end of file