From 7a7abdac2f4f3b455875690b2a27e8368c49a7e5 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Thu, 5 Oct 2017 13:16:05 -0500 Subject: [PATCH] [RN] Fix the submission of room-lock Dialogs --- .../base/dialog/components/Dialog.native.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/react/features/base/dialog/components/Dialog.native.js b/react/features/base/dialog/components/Dialog.native.js index 8e0f13985..d0074c087 100644 --- a/react/features/base/dialog/components/Dialog.native.js +++ b/react/features/base/dialog/components/Dialog.native.js @@ -45,6 +45,33 @@ class Dialog extends AbstractDialog { bodyKey: PropTypes.string }; + state = { + /** + * The text of the {@link TextInput} rendered by {@link Prompt} in + * general and by this {@code Dialog} in particular if no + * {@code children} are specified to it. It mimics/reimplements the + * functionality of {@code Prompt} because this {@code Dialog} does not + * really render the (whole) {@code Prompt}. + * + * @type {string} + */ + text: '' + }; + + /** + * Initailizes a new {@code Dialog} instance. + * + * @param {Object} props - The read-only React {@code Component} props with + * which the new instance is to be initialized. + */ + constructor(props: Object) { + super(props); + + // Bind event handlers so they are only bound once per instance. + this._onChangeText = this._onChangeText.bind(this); + this._onSubmit = this._onSubmit.bind(this); + } + /** * Implements React's {@link Component#render()}. * @@ -78,7 +105,9 @@ class Dialog extends AbstractDialog { void; + + /** + * Notifies this {@code Dialog} that the text/value of the {@code TextInput} + * rendered by {@code Prompt} has changed. + * + * @param {string} text - The new text/value of the {@code TextInput} + * rendered by {@code Prompt}. + * @returns {void} + */ + _onChangeText(text: string) { + this.setState({ text }); + } + + /** + * Submits this {@code Dialog} with the value of the {@link TextInput} + * rendered by {@link Prompt} unless a value is explicitly specified. + * + * @override + * @param {string} [value] - The submitted value if any. + * @returns {void} + */ + _onSubmit(value: ?string) { + super._onSubmit(value || this.state.text); + } } export default translate(connect()(Dialog));