-
Notifications
You must be signed in to change notification settings - Fork 378
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
[Bug?]: .pending not updating on submit of Form #1091
Comments
Ok, issue is isolated to the Does this work with the Progressively Enhanced |
Without capital |
Ah @ryansolid, I see what I've managed to do. I've tried to combine two different sets of code and have succeeded in getting neither right! Thanks so much for replying, and all the effort you've put into an incredible framework. |
Package update + rebuild+ clearing the cache seems to be working. Cheers!
import { createServerAction$, redirect } from "solid-start/server";
import { client } from "~/utils/graphql-client";
import { insertProductsUomMutation } from "./queries";
import { Show } from "solid-js";
import { FormError } from "solid-start";
// https://github.com/niliadu/solid-js-form
export default function ProductUomForm() {
const [mutating, { Form }] = createServerAction$(
// this is the request from the front end
async (form: FormData, { request }) => {
const uom_desc = form.get("uom_desc") as string;
throw new FormError("unknown error");
// await client.mutation(insertProductsUomMutation, { uom_desc });
// return redirect("/dashboard/products/uoms");
}
);
console.log("pending", mutating.pending);
return (
<>
{/* Comment Form */}
<div class="max-w-[85rem] px-4 py-10 sm:px-6 lg:px-8 lg:py-14 mx-auto">
<Show when={mutating.error}>
<p role="alert" id="error-message">
Error: {mutating.error.message}
</p>
</Show>
<div class="mx-auto max-w-2xl">
<div class="text-center">
<h2 class="text-xl text-gray-800 font-bold sm:text-3xl dark:text-white">
Add a unit of measure
</h2>
</div>
{/* Card */}
<div class="mt-5 p-4 relative z-10 bg-white border rounded-xl sm:mt-10 md:p-10 dark:bg-gray-800 dark:border-gray-700">
<Form>
<div class="mb-4 sm:mb-8">
<label
for="hs-feedback-post-comment-name-1"
class="block mb-2 text-sm font-medium dark:text-white"
>
Description
</label>
<input
type="text"
name="uom_desc"
id="hs-uom-desc"
class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 sm:p-4 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400"
placeholder="each"
required
/>
</div>
<div class="mt-6 grid">
<button
type="submit"
class="py-3 px-4 inline-flex justify-center items-center gap-2 rounded-md border border-transparent font-semibold bg-blue-500 text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-all dark:focus:ring-offset-gray-800"
disabled={mutating.pending}
>
{/* TODO: this doesn't seem to be working */}
<Show when={mutating.pending}>
<span
class="animate-spin inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-white rounded-full"
role="status"
aria-label="loading"
></span>
</Show>
Submit
</button>
</div>
</Form>
</div>
{/* End Card */}
</div>
</div>
{/* End Comment Form */}
</>
);
} Console logs:
|
Updated packages and changed |
Duplicates
Latest version
Current behavior 😯
Given the code below, the pending spinner and error message are never shown.
Expected behavior 🤔
Basically, the page, on submit, should display
an error after settingthe spinner on the button.Steps to reproduce 🕹
Steps:
Context 🔦
Feedback from forms is impossible.
Your environment 🌎
The text was updated successfully, but these errors were encountered: