Skip to content

bug: Form-associated Stencil component with type="submit" does not submit form in React #776

@a7medm7med

Description

@a7medm7med

Prerequisites

Stencil Version

4.43.3

Current Behavior

When using a Stencil component with formAssociated: true and setting the type prop to "submit", clicking the component does not submit the form when used inside a React application.

The component behaves correctly when used in native HTML (without any framework) — clicking the button submits the form as expected.

So far this issue appears only when the component is used in React. I have not yet tested it with other frameworks.

NOTE: In the production, I use react-output-target version 0.5.3 but I also tested on the latest version, and still the same issue.

@johnjenkins

Expected Behavior

When a Stencil component is configured with formAssociated: true and the type prop is set to "submit", clicking the component should trigger the native form submission, regardless of the framework used (including React).

System Info

System: node 22.22.0
    Platform: windows (10.0.26200)
   CPU Model: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz (12 cpus)
    Compiler: D:\Work\Projects\node_modules\.pnpm\@stencil+core@4.43.2\node_modules\@stencil\core\compiler\stencil.js
       Build: 1772184285
     Stencil: 4.43.2
  TypeScript: 5.8.3
      Rollup: 4.44.0
      Parse5: 7.2.1
      jQuery: 4.0.0-pre
      Terser: 5.37.0

Steps to Reproduce

  1. Install dependencies - pnpm -r i
  2. Build the project - pnpm -r build
  3. Navigate to the example React app
  4. cd packages/my-app
  5. Run the development server - pnpm run dev
  6. Open the provided production URL and test the form.
  7. Click the Stencil component with type="submit".

Code Reproduction URL

https://github.com/a7medm7med/stencil-button-submit-issue

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanteda good issue for the communitytype: bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions