From 3d34259e13be3ee3bc66561696e932deb7fb66bc Mon Sep 17 00:00:00 2001 From: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com> Date: Sun, 18 Jun 2023 13:22:46 +0900 Subject: [PATCH 1/7] onleydown --- islands/Room.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/islands/Room.tsx b/islands/Room.tsx index 13bf05a..13b0a85 100644 --- a/islands/Room.tsx +++ b/islands/Room.tsx @@ -91,6 +91,9 @@ export default class extends Component { { + alert(0) + }} class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" /> From eddd3523c7f06dcd7b13857866dc328c0f5bd2f2 Mon Sep 17 00:00:00 2001 From: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com> Date: Sun, 18 Jun 2023 13:33:07 +0900 Subject: [PATCH 5/7] cansubmit --- islands/Room.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/islands/Room.tsx b/islands/Room.tsx index 4906b4d..22a7547 100644 --- a/islands/Room.tsx +++ b/islands/Room.tsx @@ -96,7 +96,9 @@ export default class extends Component { inp.current.value = "" } } - const [isOpenMenu, setIsOpenMenu] = useState(false) + const [isOpenMenu, setIsOpenMenu] = useState(false) // メニューがオンか + const [canSubmit, setCanSubmit] = useState(false) // 送信可能か + return ( <>
@@ -113,6 +115,9 @@ export default class extends Component { sendMessage() } }} + onInput={(e)=>{ + setCanSubmit(e.target.value !== "") + }} class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" /> From c6c3558ecffa486a57f89093d0db0083ad045538 Mon Sep 17 00:00:00 2001 From: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com> Date: Sun, 18 Jun 2023 13:38:38 +0900 Subject: [PATCH 6/7] opacity --- islands/Room.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/islands/Room.tsx b/islands/Room.tsx index 22a7547..125726d 100644 --- a/islands/Room.tsx +++ b/islands/Room.tsx @@ -79,6 +79,7 @@ export default class extends Component { inp.current.value += " >>" + msg + " "; } } + const [canSubmit, setCanSubmit] = useState(false) // 送信可能か const sendMessage = (): void => { if (inp.current?.value === "") { alert( @@ -95,9 +96,9 @@ export default class extends Component { // 文字の消去 inp.current.value = "" } + setCanSubmit(false) } const [isOpenMenu, setIsOpenMenu] = useState(false) // メニューがオンか - const [canSubmit, setCanSubmit] = useState(false) // 送信可能か return ( <> @@ -126,6 +127,9 @@ export default class extends Component { }} class="mx-5 bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded inline-flex items-center" disabled={!canSubmit} + style={{ + opacity: canSubmit ? 1 : 0.5 + }} > From 5f10b74ee0e18db4c715996ccf8175e7fd96d125 Mon Sep 17 00:00:00 2001 From: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com> Date: Sun, 18 Jun 2023 13:40:58 +0900 Subject: [PATCH 7/7] fix --- islands/Room.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/islands/Room.tsx b/islands/Room.tsx index 125726d..cc4b950 100644 --- a/islands/Room.tsx +++ b/islands/Room.tsx @@ -81,11 +81,8 @@ export default class extends Component { } const [canSubmit, setCanSubmit] = useState(false) // 送信可能か const sendMessage = (): void => { - if (inp.current?.value === "") { - alert( - "送信できませんでした。 送信内容が空の可能性が有ります。" - ); - return; + if(!(inp.current?.value)){ + return } this.state.socket.emit("message", { body: inp.current?.value,