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.
This commit is contained in:
@@ -20,7 +20,7 @@ templ LoginPage() {
|
||||
type="text"
|
||||
placeholder="Enter your username"
|
||||
data-bind="username"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
|
||||
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/login") }
|
||||
autofocus
|
||||
/>
|
||||
<label class="label" for="password">Password</label>
|
||||
@@ -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") }
|
||||
/>
|
||||
</fieldset>
|
||||
<button
|
||||
|
||||
@@ -20,7 +20,7 @@ templ RegisterPage() {
|
||||
type="text"
|
||||
placeholder="Choose a username"
|
||||
data-bind="username"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/register") }
|
||||
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/register") }
|
||||
autofocus
|
||||
/>
|
||||
<label class="label" for="password">Password</label>
|
||||
@@ -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") }
|
||||
/>
|
||||
<label class="label" for="confirm">Confirm Password</label>
|
||||
<input
|
||||
@@ -39,7 +39,7 @@ templ RegisterPage() {
|
||||
type="password"
|
||||
placeholder="Confirm your password"
|
||||
data-bind="confirm"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/register") }
|
||||
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/register") }
|
||||
/>
|
||||
</fieldset>
|
||||
<button
|
||||
|
||||
@@ -28,7 +28,7 @@ templ NicknamePrompt(returnPath string) {
|
||||
type="text"
|
||||
placeholder="Enter your nickname"
|
||||
data-bind="nickname"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("%s", returnPath) }
|
||||
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("%s", returnPath) }
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
|
||||
@@ -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") }
|
||||
/>
|
||||
</fieldset>
|
||||
<button
|
||||
|
||||
@@ -34,7 +34,7 @@ templ GamePage(sg *snake.SnakeGame, mySlot int, messages []chat.Message, chatCfg
|
||||
class="snake-wrapper flex flex-col items-center gap-4 p-4"
|
||||
data-signals={ `{"chatMsg":""}` }
|
||||
data-init={ datastar.GetSSE("/snake/%s/events", gameID) }
|
||||
data-on:keydown.throttle_100ms={ keydownScript(gameID) }
|
||||
data-on:keydown__throttle.100ms={ keydownScript(gameID) }
|
||||
tabindex="0"
|
||||
>
|
||||
@GameContent(sg, mySlot, messages, chatCfg, gameID)
|
||||
|
||||
Reference in New Issue
Block a user