From 3c08b575df63aa251a5e1f9e85cecfeb762b5acf Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 15 Aug 2018 13:15:40 -0400 Subject: [PATCH] submit on enter for whisper --- templates/demo/app/components/whisper.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/templates/demo/app/components/whisper.js b/templates/demo/app/components/whisper.js index 3c056bf21..29d2bb27c 100644 --- a/templates/demo/app/components/whisper.js +++ b/templates/demo/app/components/whisper.js @@ -22,6 +22,14 @@ class Whisper extends React.Component { this.setState(this.state); } + checkEnter(e, func) { + if (e.key !== 'Enter') { + return; + } + e.preventDefault(); + func.apply(this, [e]); + } + sendMessage (e) { e.preventDefault(); EmbarkJS.Messages.sendMessage({topic: this.state.channel, data: this.state.message}); @@ -68,7 +76,7 @@ class Whisper extends React.Component { : '' }

Listen To channel

-
+ this.checkEnter(e, this.listenToChannel)}>

Send Message

- + this.checkEnter(e, this.sendMessage)}>