From 64b5d384ed544136e2c08a66b1e49c1c0beaea7b Mon Sep 17 00:00:00 2001
From: Ryan Hamamura <58859899+ryanhamamura@users.noreply.github.com>
Date: Mon, 2 Mar 2026 23:05:11 -1000
Subject: [PATCH] fix: use correct Datastar keydown event syntax
Replace invalid .key_enter and .enter modifiers with evt.key === 'Enter'
guard in the expression, per Datastar docs. Also fix __stop and __throttle
modifier syntax to use double underscores.
---
chat/components/chat.templ | 5 ++---
features/auth/pages/login.templ | 4 ++--
features/auth/pages/register.templ | 6 +++---
features/common/components/shared.templ | 2 +-
features/lobby/pages/lobby.templ | 2 +-
features/snakegame/pages/game.templ | 2 +-
6 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/chat/components/chat.templ b/chat/components/chat.templ
index ec10136..f2d02fe 100644
--- a/chat/components/chat.templ
+++ b/chat/components/chat.templ
@@ -42,8 +42,7 @@ templ Chat(messages []chat.Message, cfg Config) {
placeholder="Chat..."
autocomplete="off"
data-bind="chatMsg"
- data-on:keydown.stop=""
- data-on:keydown.key_enter={ datastar.PostSSE("%s", cfg.PostURL) }
+ data-on:keydown__stop={ "evt.key === 'Enter' && " + datastar.PostSSE("%s", cfg.PostURL) }
/>
} else {
}
@@ -30,7 +30,7 @@ templ LoginPage() {
type="password"
placeholder="Enter your password"
data-bind="password"
- data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
+ data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/login") }
/>
@@ -30,7 +30,7 @@ templ RegisterPage() {
type="password"
placeholder="Choose a password (min 8 chars)"
data-bind="password"
- data-on:keydown.key_enter={ datastar.PostSSE("/auth/register") }
+ data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/register") }
/>
diff --git a/features/lobby/pages/lobby.templ b/features/lobby/pages/lobby.templ
index c2dde2e..b6186df 100644
--- a/features/lobby/pages/lobby.templ
+++ b/features/lobby/pages/lobby.templ
@@ -73,7 +73,7 @@ templ LobbyPage(data LobbyData) {
placeholder="Enter your nickname"
data-bind="nickname"
required
- data-on:keydown.enter={ datastar.PostSSE("/games") }
+ data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/games") }
/>