solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[bug] FORM component not responding

Open mentasuave01 opened this issue 2 years ago • 4 comments

<FORM> component stop working as intented when you use <br/> tags in it Working example:

<Form>
      <label for="username">Username:</label>
       <br/>
      <input type="text" name="username" />
      <input type="submit" value="submit" />
    </Form>

mentasuave01 avatar Nov 16 '22 16:11 mentasuave01

This report isn't helpful, it's incredibly unclear what the issue actually is, and looks like it was written in a rush

Please send a reproduction using codesandbox

boehs avatar Nov 16 '22 22:11 boehs

My original message got cut, sorry for the inconvenience. clipboard command failed.

mentasuave01 avatar Nov 17 '22 00:11 mentasuave01

It's still unclear what the actual issue is. An error and (ideally)/or a reproduction will be helpful

boehs avatar Nov 17 '22 01:11 boehs

export function MyComponent() {
  const [_, { Form }] = createRouteAction(async (formData: FormData) => {
    await new Promise((resolve, reject) => setTimeout(resolve, 1000));
    const username = formData.get("username");
    if (username === "admin") {
      return redirect("/admin");
    } else {
      throw new Error("Invalid username");
    }
    return redirect("/home");
  });
 
  return (
    <Form>
      <label for="username">Username:</label>
      <input type="text" name="username" />
      <input type="submit" value="submit" />
    </Form>
  );
}

👆that is a normal form with normal form behavior

export function MyComponent() {
  const [_, { Form }] = createRouteAction(async (formData: FormData) => {
    await new Promise((resolve, reject) => setTimeout(resolve, 1000));
    const username = formData.get("username");
    if (username === "admin") {
      return redirect("/admin");
    } else {
      throw new Error("Invalid username");
    }
    return redirect("/home");
  });
 
  return (
    <Form>
      <label for="username">Username:</label>
      <br/>
      <input type="text" name="username" />
      <input type="submit" value="submit" />
    </Form>
  );
}

👆That form is broken, formData.get return an empty object

mentasuave01 avatar Nov 17 '22 18:11 mentasuave01

Hmm.. that's unusual. I feel I'm missing something.. I put a bunch of br's in the TodoMVC example that is all forms and they all still worked. Help a ton to have a reproduction.

ryansolid avatar Dec 22 '22 00:12 ryansolid

Stale/no reproduction closing.

ryansolid avatar Aug 09 '23 19:08 ryansolid