Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@Mth0158
Copy link

@Mth0158 Mth0158 commented Apr 11, 2025

This feature add the ability to have a rails-nested controller inside a rails-nested controller template. Basically it allows to nest inside another nesting.

I was not able to fix the test issue for the 2nd test. The test passes but it raises an error, anyone has any idea about how to solve this?

➜  stimulus-components git:(fix-issue-with-nested-in-nested-component) vitest --run

 RUN  v2.1.9 /Users/xxx/stimulus-components

stderr | components/rails-nested-form/spec/index.test.ts > #nestedForm > with two or more nesting levels > should create new url, not messing with the nested y form
Error invoking action "click->nested-form-x#add"

TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
    at Object.exports.convert (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/Event.js:22:9)
    at HTMLFormElement.dispatchEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:236:24)
    at extended.add (/Users/xxx/stimulus-components/components/rails-nested-form/src/index.ts:28:18)
    at Binding.invokeWithEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:391:29)
    at Binding.handleEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:356:22)
    at EventListener.handleEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:37:29)
    at HTMLButtonElement.callTheUserObjectsOperation (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
    at innerInvokeEventListeners (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
    at invokeEventListeners (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
    at HTMLButtonElementImpl._dispatch (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9) {
  [stack]: "TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.\n" +
    '    at Object.exports.convert (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/Event.js:22:9)\n' +
    '    at HTMLFormElement.dispatchEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:236:24)\n' +
    '    at extended.add (/Users/xxx/stimulus-components/components/rails-nested-form/src/index.ts:28:18)\n' +
    '    at Binding.invokeWithEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:391:29)\n' +
    '    at Binding.handleEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:356:22)\n' +
    '    at EventListener.handleEvent (/Users/xxx/stimulus-components/node_modules/.pnpm/@hotwired+stimulus@3.2.2/node_modules/@hotwired/stimulus/dist/stimulus.umd.js:37:29)\n' +
    '    at HTMLButtonElement.callTheUserObjectsOperation (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)\n' +
    '    at innerInvokeEventListeners (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)\n' +
    '    at invokeEventListeners (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)\n' +
    '    at HTMLButtonElementImpl._dispatch (/Users/xxx/stimulus-components/node_modules/.pnpm/jsdom@20.0.3/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)',
  [message]: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'."
}

{
  identifier: 'nested-form-x',
  controller: <ref *3> extended {
    context: <ref *1> Context {
      logDebugActivity: [Function (anonymous)] { [length]: 1, [name]: '' },
      module: Module {
        application: Application {
          logger: [Console],
          debug: false,
          logDebugActivity: [Function],
          element: [HTMLHtmlElement],
          schema: [Object],
          dispatcher: [Dispatcher],
          router: [Router],
          actionDescriptorFilters: [Object],
          [controllers]: [Getter]
        },
        definition: {
          identifier: 'nested-form-x',
          controllerConstructor: [Function]
        },
        contextsByScope: WeakMap { [Scope] => [Circular *1] },
        connectedContexts: Set(1) { [Circular *1] },
        [identifier]: [Getter],
        [controllerConstructor]: [Getter],
        [contexts]: [Getter]
      },
      scope: <ref *2> Scope {
        targets: TargetSet {
          scope: [Circular *2],
...
 ✓ components/auto-submit/spec/index.test.ts (2)
 ✓ components/character-counter/spec/index.test.ts (2)
 ✓ components/checkbox-select-all/spec/index.test.ts (3)
 ✓ components/confirmation/spec/index.test.ts (6)
 ✓ components/password-visibility/spec/index.test.ts (1)
 ✓ components/rails-nested-form/spec/index.test.ts (4)
 ✓ components/reveal-controller/spec/index.test.ts (1)
 ✓ components/timeago/spec/index.test.ts (5)

 Test Files  8 passed (8)
      Tests  24 passed (24)
   Start at  12:21:24
   Duration  1.53s (transform 534ms, setup 0ms, collect 864ms, tests 717ms, environment 3.99s, prepare 513ms)

@Mth0158 Mth0158 marked this pull request as draft April 11, 2025 10:25
@Mth0158 Mth0158 force-pushed the fix-issue-with-nested-in-nested-component branch from f9f8294 to 9a5cb5f Compare April 11, 2025 10:30
@Mth0158 Mth0158 marked this pull request as ready for review April 11, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.