fix: handle target attribute on remote form redirects#15457
Merged
teemingc merged 10 commits intosveltejs:mainfrom Mar 6, 2026
Merged
fix: handle target attribute on remote form redirects#15457teemingc merged 10 commits intosveltejs:mainfrom
teemingc merged 10 commits intosveltejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: e530b52 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 |
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Contributor
Author
|
@teemingc can you please review this PR ? Thank you |
teemingc
reviewed
Mar 5, 2026
packages/kit/src/runtime/client/remote-functions/form.svelte.js
Outdated
Show resolved
Hide resolved
teemingc
reviewed
Mar 5, 2026
packages/kit/src/runtime/client/remote-functions/form.svelte.js
Outdated
Show resolved
Hide resolved
teemingc
reviewed
Mar 5, 2026
packages/kit/src/runtime/client/remote-functions/form.svelte.js
Outdated
Show resolved
Hide resolved
teemingc
reviewed
Mar 5, 2026
teemingc
reviewed
Mar 5, 2026
teemingc
reviewed
Mar 5, 2026
packages/kit/test/apps/async/src/routes/remote/form/redirect-target/+page.svelte
Show resolved
Hide resolved
teemingc
requested changes
Mar 5, 2026
Member
teemingc
left a comment
There was a problem hiding this comment.
Thanks for the PR! There are some additional edge cases we need to account for which I've highlighted in the comments. Also, there might be a way to simplify the window opening handling.
Contributor
Author
|
Hey @teemingc, thanks for the detailed review. I have updated the code and yes there was a better way of handling this, I tried to implement that and also added an additional test. |
teemingc
reviewed
Mar 5, 2026
packages/kit/src/runtime/client/remote-functions/form.svelte.js
Outdated
Show resolved
Hide resolved
Merged
Copilot AI
pushed a commit
to Stadly/kit
that referenced
this pull request
Mar 6, 2026
closes sveltejs#15197 --- - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed. --- ### Problem Remote forms with ```target="_blank"``` did not open the redirect destination in a new tab. Instead, the current tab would navigate to the redirect URL, making ```target="_blank"``` completely ignored for both internal and external redirects. ### Solution Check the form element's target attribute before deciding how to navigate. If it's``` _blank``` or ```_new```, use ```window.open()``` instead of ```_goto()``` I have ran all the tests and there were no issues. --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by: Tee Ming <chewteeming01@gmail.com>
elliott-with-the-longest-name-on-github
pushed a commit
that referenced
this pull request
Mar 11, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @sveltejs/kit@2.54.0 ### Minor Changes - feat: allow error boundaries to catch errors on the server ([#15308](#15308)) ### Patch Changes - chore: upgrade `devalue` ([#15535](#15535)) - fix: don't wait for remote functions that are not awaited in the template ([#15280](#15280)) - feat: allow `resolve()` to accept pathnames with a search string and/or hash ([#15458](#15458)) - chore: remove deprecation warnings for `config.kit.files.*` options when validating the Svelte config file ([#15482](#15482)) - fix: handles form target attribute in remote form redirects ([#15457](#15457)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
dlrobson
added a commit
to dlrobson/dlrobson.github.io
that referenced
this pull request
Mar 22, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@sveltejs/kit](https://svelte.dev) ([source](https://github.com/sveltejs/kit/tree/HEAD/packages/kit)) | [`2.53.4` → `2.55.0`](https://renovatebot.com/diffs/npm/@sveltejs%2fkit/2.53.4/2.55.0) |  |  | --- ### Release Notes <details> <summary>sveltejs/kit (@​sveltejs/kit)</summary> ### [`v2.55.0`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#2550) [Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/kit@2.54.0...@sveltejs/kit@2.55.0) ##### Minor Changes - feat: page and layout params with matchers are now type narrowed in `$app/types`, leading to better type safety when working with params in `$app/types`, `$app/state`, and hooks. ([#​15502](sveltejs/kit#15502)) ### [`v2.54.0`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#2540) [Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/kit@2.53.4...@sveltejs/kit@2.54.0) ##### Minor Changes - feat: allow error boundaries to catch errors on the server ([#​15308](sveltejs/kit#15308)) ##### Patch Changes - chore: upgrade `devalue` ([#​15535](sveltejs/kit#15535)) - fix: don't wait for remote functions that are not awaited in the template ([#​15280](sveltejs/kit#15280)) - feat: allow `resolve()` to accept pathnames with a search string and/or hash ([#​15458](sveltejs/kit#15458)) - chore: remove deprecation warnings for `config.kit.files.*` options when validating the Svelte config file ([#​15482](sveltejs/kit#15482)) - fix: handles form target attribute in remote form redirects ([#​15457](sveltejs/kit#15457)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44NC4yIiwidXBkYXRlZEluVmVyIjoiNDMuODQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://forgejo.tail5a98.ts.net/gooilers123/monolith/pulls/45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #15197
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits
Problem
Remote forms with
target="_blank"did not open the redirect destination in a new tab. Instead, the current tab would navigate to the redirect URL, makingtarget="_blank"completely ignored for both internal and external redirects.Solution
Check the form element's target attribute before deciding how to navigate. If it's
_blankor_new, usewindow.open()instead of_goto()I have ran all the tests and there were no issues.