fix: support coordinate objects from image inputs in remote forms - #16944
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/415fcdcea8ae9ebb5b29c963b0278f4ca85eb06dOpen in |
🦋 Changeset detectedLatest commit: 415fcdc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment was marked as resolved.
This comment was marked as resolved.
|
if (event.submitter && /** @type {HTMLInputElement} */ (event.submitter).type !== 'image') { |
|
The default-submitter selector in |
Fixes a pre-existing async live-query test flake observed on #16944 in CI run https://github.com/sveltejs/kit/actions/runs/32994679500. The stats button previously awaited `get_stats()` without first refreshing its cached query. Cache eviction therefore depended on `FinalizationRegistry`/GC timing, and CI polling could repeatedly read the original `cleanup_count` after reconnecting. Explicitly start a refresh, then await `get_stats()` again. Query proxies for the same query share the cached resource, so the second proxy resolves with fresh server state while using the idiomatic remote-query API. The follow-up passed async-app type checking, formatting, and diff validation. A targeted Playwright build also completed, though browser launch was unavailable in the sandbox because required Chromium system libraries could not be installed. --------- Co-authored-by: svelte-triage-bot <team@svelte.com>
|
/autofix |

I was today years old when I discovered
<input type="image" />and how it works and it got me unreasonably excited. So obviously, I had to try if it worked correctly with remote functions, and it turns out it doesn't.This PR fixes that.
How it works in HTML
Initially, I thought that
<input type="image" />was just to show an image as a submit button, a relic of an era where you couldn't properly style buttons. But it turns out that it does something much more interesting. Because when you submit a form with<input type="image" />two properties are added to theFormData(or to the search):name.xandname.ywith the coordinates of where the pointer was (inside the image) when it was clicked.I legit never used it, but I can see how this could sometimes be necessary, and it would be a shame to lose this progressive enhanced functionality.
The fix
The fix works both type wise and runtime wise by allowing the user to declare
as("image")when the field is an object withxandyas numbers.A few important notes:
field.as("image")as you would have no way to set the last propertyfield.x.as("text")andfield.y.as("text")so if by chance you have an{ x: number; y: number }schema, but it's not for animageinput you can still use them.Now the kind-of bad news: I think this is a breaking change in case someone was using
as("image")on a field which was not{ x: number; y: number }...however this would've error at runtime before (because of the extra fields) so maybe is acceptable?P.s. I know AIs love to write in paragraphs, but this was handwritten lol