fix(welcome-page): prevent form submit to prevent page refresh

This commit is contained in:
Leonard Kim 2018-03-30 12:49:34 -07:00 committed by Дамян Минков
parent 358ce0799e
commit b76ab305e3
1 changed files with 15 additions and 1 deletions

View File

@ -55,6 +55,7 @@ class WelcomePage extends AbstractWelcomePage {
'welcome-page-additional-content-template');
// Bind event handlers so they are only bound once per instance.
this._onFormSubmit = this._onFormSubmit.bind(this);
this._onRoomChange = this._onRoomChange.bind(this);
this._setAdditionalContentRef
= this._setAdditionalContentRef.bind(this);
@ -121,7 +122,7 @@ class WelcomePage extends AbstractWelcomePage {
<div id = 'new_enter_room'>
<form
className = 'enter-room-input'
onSubmit = { this._onJoin }>
onSubmit = { this._onFormSubmit }>
<FieldTextStateless
autoFocus = { true }
id = 'enter_room_field'
@ -153,6 +154,19 @@ class WelcomePage extends AbstractWelcomePage {
);
}
/**
* Prevents submission of the form and delagates join logic.
*
* @param {Event} event - The HTML Event which details the form submission.
* @private
* @returns {void}
*/
_onFormSubmit(event) {
event.preventDefault();
this._onJoin();
}
/**
* Overrides the super to account for the differences in the argument types
* provided by HTML and React Native text inputs.