From c6f90ece277080b721267d6969c45340ad5e5b22 Mon Sep 17 00:00:00 2001 From: Kevin Cameron Date: Tue, 6 Mar 2018 23:16:37 -0800 Subject: [PATCH] Change modal to form --- src/modal/title.js | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/modal/title.js b/src/modal/title.js index b3097d0..82127bf 100644 --- a/src/modal/title.js +++ b/src/modal/title.js @@ -5,44 +5,44 @@ import state from "../state"; import css from "./title.css"; export default { - view : (vnode) => [ - m("input", { - value : vnode.state.value, - placeholder : state.song.title, - class : css.input, - onkeydown : (e) => { - if(e.keyCode === 13 && vnode.state.value) { + view : (vnode) => + m("form", { + onsubmit : (e) => { + e.preventDefault(); + + if(!vnode.state.value) { + return; + } + state.action("ADD TITLE", vnode.state.value); } }, - oninput : m.withAttr("value", (v) => { - vnode.state.value = v; + m("input", { + value : vnode.state.value, + placeholder : state.song.title, + class : css.input, + oninput : m.withAttr("value", (v) => { + vnode.state.value = v; + }), + oncreate : (inputVnode) => { + inputVnode.dom.focus(); + } }), - oncreate : (inputVnode) => { - inputVnode.dom.focus(); - } - }), - m("div", { class : css.buttons }, - m("button", { - class : css.add, - onclick : () => { - if(!vnode.state.value) { - return; + m("div", { class : css.buttons }, + m("button", { + type : "submit", + class : css.add + }, + "add title" + ), + m("button", { + class : css.cancel, + onclick : () => { + state.action("CLOSE MODAL"); } - - state.action("ADD TITLE", vnode.state.value); - } - }, - "add title" - ), - m("button", { - class : css.cancel, - onclick : () => { - state.action("CLOSE MODAL"); - } - }, - "cancel" + }, + "cancel" + ) ) ) - ] };