From 375cdbdb13d73abbab185980c3047c781e830df9 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 15 May 2017 10:08:25 -0400 Subject: Pressing Enter submits Leave Team Modal (#6096) --- webapp/components/leave_team_modal.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webapp') diff --git a/webapp/components/leave_team_modal.jsx b/webapp/components/leave_team_modal.jsx index 4728fb16d..379ece4c3 100644 --- a/webapp/components/leave_team_modal.jsx +++ b/webapp/components/leave_team_modal.jsx @@ -20,6 +20,7 @@ class LeaveTeamModal extends React.Component { this.handleToggle = this.handleToggle.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.handleHide = this.handleHide.bind(this); + this.handleKeyPress = this.handleKeyPress.bind(this); this.state = { show: false @@ -28,10 +29,18 @@ class LeaveTeamModal extends React.Component { componentDidMount() { ModalStore.addModalListener(ActionTypes.TOGGLE_LEAVE_TEAM_MODAL, this.handleToggle); + document.addEventListener('keypress', this.handleKeyPress); } componentWillUnmount() { ModalStore.removeModalListener(ActionTypes.TOGGLE_LEAVE_TEAM_MODAL, this.handleToggle); + document.removeEventListener('keypress', this.handleKeyPress); + } + + handleKeyPress(e) { + if (e.key === 'Enter' && this.state.show) { + this.handleSubmit(e); + } } handleToggle(value) { -- cgit v1.2.3-1-g7c22