Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions: New fallback behavior with action={actions.name} #11570

Merged
merged 16 commits into from
Jul 30, 2024

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Jul 29, 2024

Changes

Introduce the new pattern action={actions.name} for form fallbacks. This replaces the previous getActionProps() pattern.

---
import { actions } from 'astro:actions';
---

<form method="POST" action={actions.logOut}>
  <button>Log Out</button>
</form>
  • Deprecate getActionProps()
  • Allow actions to return a string
  • Introduce .queryString as an action property for more explicit URL construction
  • Update React 19 handler to also use a query string for form actions

Testing

  • Add integration tests for new pattern, marking old tests as legacy
  • Check that e2e tests still pass

Docs

RFC updates to be pushed on minor release

Copy link

changeset-bot bot commented Jul 29, 2024

🦋 Changeset detected

Latest commit: 91ddd65

The changes in this PR will be included in the next version bump.

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

@github-actions github-actions bot added pkg: react Related to React (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review semver: minor Change triggers a `minor` release labels Jul 29, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@bholmesdev bholmesdev marked this pull request as ready for review July 29, 2024 18:34
@bholmesdev
Copy link
Contributor Author

Reason for the minor: this is a breaking change for the React integration. It's otherwise non-breaking since getActionProps() still has a legacy handler.

@matthewp
Copy link
Contributor

My only pause here is will people understand that the POST will return to this current Astro page? I might find that confusing without knowing. I guess if people do then we could add the onSuccess / onError options like previously discussed.

@bholmesdev bholmesdev force-pushed the feat/new-action-fallback branch from 8cf7709 to c3440a2 Compare July 29, 2024 20:38
@bholmesdev
Copy link
Contributor Author

@matthewp Totally understand the concern. This API was chosen due to the precedent React and SvelteKit have set for actions returning to the current page. I'd expect the pattern to feel nicer for our majority userbase.

We are waiting another 2 weeks for a minor release, so that should give us time to get user feedback on the change. I will also rework the RFC docs to better explain the pattern for those that (inevitably) use this in a .astro file.

@bholmesdev bholmesdev merged commit 84189b6 into main Jul 30, 2024
13 checks passed
@bholmesdev bholmesdev deleted the feat/new-action-fallback branch July 30, 2024 15:04
@astrobot-houston astrobot-houston mentioned this pull request Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: react Related to React (scope) pr: docs A PR that includes documentation for review semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants