diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-03-22 23:05:44 +0100 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-03-22 23:05:44 +0100 |
commit | 55d538554b952fd63659b63839df0f72b1795da3 (patch) | |
tree | 7a87fcdc1031e025ac6367ea2ab7b78d081a9116 /sw-ui-kt | |
parent | Fix player order by adding placeholders before shifting (diff) | |
download | seven-wonders-55d538554b952fd63659b63839df0f72b1795da3.tar.gz seven-wonders-55d538554b952fd63659b63839df0f72b1795da3.tar.bz2 seven-wonders-55d538554b952fd63659b63839df0f72b1795da3.zip |
Fix home refresh on enter key
Diffstat (limited to 'sw-ui-kt')
-rw-r--r-- | sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt index 94058131..91f6e291 100644 --- a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt +++ b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt @@ -8,6 +8,7 @@ import kotlinx.html.js.onSubmitFunction import org.luxons.sevenwonders.ui.redux.RequestChooseName import org.luxons.sevenwonders.ui.redux.connectDispatch import org.w3c.dom.HTMLInputElement +import org.w3c.dom.events.Event import react.RBuilder import react.RClass import react.RComponent @@ -30,7 +31,7 @@ private class ChooseNameForm(props: ChooseNameFormProps): RComponent<ChooseNameF override fun RBuilder.render() { form { - attrs.onSubmitFunction = { props.chooseUsername(state.username) } + attrs.onSubmitFunction = { e -> chooseUsername(e) } inputGroup( large = true, placeholder = "Username", @@ -48,9 +49,14 @@ private class ChooseNameForm(props: ChooseNameFormProps): RComponent<ChooseNameF minimal = true, icon = "arrow-right", intent = Intent.PRIMARY, - onClick = { props.chooseUsername(state.username) } + onClick = { e -> chooseUsername(e) } ) } + + private fun chooseUsername(e: Event) { + e.preventDefault() + props.chooseUsername(state.username) + } } val chooseNameForm: RClass<RProps> = connectDispatch(ChooseNameForm::class) { dispatch, _ -> |