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:
@@ -42,8 +42,7 @@ templ Chat(messages []chat.Message, cfg Config) {
|
|||||||
placeholder="Chat..."
|
placeholder="Chat..."
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
data-bind="chatMsg"
|
data-bind="chatMsg"
|
||||||
data-on:keydown.stop=""
|
data-on:keydown__stop={ "evt.key === 'Enter' && " + datastar.PostSSE("%s", cfg.PostURL) }
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("%s", cfg.PostURL) }
|
|
||||||
/>
|
/>
|
||||||
} else {
|
} else {
|
||||||
<input
|
<input
|
||||||
@@ -51,7 +50,7 @@ templ Chat(messages []chat.Message, cfg Config) {
|
|||||||
placeholder="Chat..."
|
placeholder="Chat..."
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
data-bind="chatMsg"
|
data-bind="chatMsg"
|
||||||
data-on:keydown.enter={ datastar.PostSSE("%s", cfg.PostURL) }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("%s", cfg.PostURL) }
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ templ LoginPage() {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Enter your username"
|
placeholder="Enter your username"
|
||||||
data-bind="username"
|
data-bind="username"
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/login") }
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
<label class="label" for="password">Password</label>
|
<label class="label" for="password">Password</label>
|
||||||
@@ -30,7 +30,7 @@ templ LoginPage() {
|
|||||||
type="password"
|
type="password"
|
||||||
placeholder="Enter your password"
|
placeholder="Enter your password"
|
||||||
data-bind="password"
|
data-bind="password"
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/login") }
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ templ RegisterPage() {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Choose a username"
|
placeholder="Choose a username"
|
||||||
data-bind="username"
|
data-bind="username"
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/register") }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/register") }
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
<label class="label" for="password">Password</label>
|
<label class="label" for="password">Password</label>
|
||||||
@@ -30,7 +30,7 @@ templ RegisterPage() {
|
|||||||
type="password"
|
type="password"
|
||||||
placeholder="Choose a password (min 8 chars)"
|
placeholder="Choose a password (min 8 chars)"
|
||||||
data-bind="password"
|
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>
|
<label class="label" for="confirm">Confirm Password</label>
|
||||||
<input
|
<input
|
||||||
@@ -39,7 +39,7 @@ templ RegisterPage() {
|
|||||||
type="password"
|
type="password"
|
||||||
placeholder="Confirm your password"
|
placeholder="Confirm your password"
|
||||||
data-bind="confirm"
|
data-bind="confirm"
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/register") }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/auth/register") }
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ templ NicknamePrompt(returnPath string) {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Enter your nickname"
|
placeholder="Enter your nickname"
|
||||||
data-bind="nickname"
|
data-bind="nickname"
|
||||||
data-on:keydown.key_enter={ datastar.PostSSE("%s", returnPath) }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("%s", returnPath) }
|
||||||
required
|
required
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ templ LobbyPage(data LobbyData) {
|
|||||||
placeholder="Enter your nickname"
|
placeholder="Enter your nickname"
|
||||||
data-bind="nickname"
|
data-bind="nickname"
|
||||||
required
|
required
|
||||||
data-on:keydown.enter={ datastar.PostSSE("/games") }
|
data-on:keydown={ "evt.key === 'Enter' && " + datastar.PostSSE("/games") }
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button
|
<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"
|
class="snake-wrapper flex flex-col items-center gap-4 p-4"
|
||||||
data-signals={ `{"chatMsg":""}` }
|
data-signals={ `{"chatMsg":""}` }
|
||||||
data-init={ datastar.GetSSE("/snake/%s/events", gameID) }
|
data-init={ datastar.GetSSE("/snake/%s/events", gameID) }
|
||||||
data-on:keydown.throttle_100ms={ keydownScript(gameID) }
|
data-on:keydown__throttle.100ms={ keydownScript(gameID) }
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
@GameContent(sg, mySlot, messages, chatCfg, gameID)
|
@GameContent(sg, mySlot, messages, chatCfg, gameID)
|
||||||
|
|||||||
Reference in New Issue
Block a user