Skip to content

Namespace Stimulus controllers with coplan-- prefix#40

Merged
HamptonMakes merged 2 commits intomainfrom
hampton/namespace-stimulus-controllers
Mar 6, 2026
Merged

Namespace Stimulus controllers with coplan-- prefix#40
HamptonMakes merged 2 commits intomainfrom
hampton/namespace-stimulus-controllers

Conversation

@HamptonMakes
Copy link
Collaborator

What

Update all engine view templates to use the coplan-- namespace prefix for Stimulus controller identifiers (e.g., coplan--text-selection, coplan--tabs, coplan--dropdown).

Why

The engine's importmap pins controllers under controllers/coplan, which Stimulus registers with the coplan-- prefix. But the views were referencing non-namespaced identifiers (text-selection, tabs, dropdown), which only worked in the main coplan app because it had duplicate copies at the non-namespaced path.

Host apps like coplan-square that rely solely on the engine's importmap never loaded the controllers — text selection popover, Open/Resolved tabs, and the dropdown menu were all silently broken.

Changes

  • show.html.erbtext-selectioncoplan--text-selection, tabscoplan--tabs
  • _header.html.erbdropdowncoplan--dropdown
  • _new_comment_form.html.erb — all text-selection targets/actions → coplan--text-selection
  • _reply_form.html.erbtext-selection action → coplan--text-selection
  • _thread.html.erbtext-selection action → coplan--text-selection

HamptonMakes and others added 2 commits March 5, 2026 15:16
The engine's importmap pins controllers under controllers/coplan,
which registers them as coplan--text-selection, coplan--tabs, etc.
in Stimulus. The views were referencing non-namespaced identifiers
(text-selection, tabs, dropdown) which only worked in the main
coplan app because it had duplicate copies of the controllers at
the non-namespaced path. Host apps like coplan-square that rely
solely on the engine's importmap never loaded the controllers.

Update all data-controller, data-*-target, and data-action
attributes to use the coplan-- namespace prefix.

Amp-Thread-ID: https://ampcode.com/threads/T-019cbf49-a8fa-739b-9d02-f3f3eab982f4
Co-authored-by: Amp <amp@ampcode.com>
These were duplicates of the engine controllers at the non-namespaced
path. Now that views use coplan-- prefixed identifiers, the engine's
importmap (controllers/coplan/*) provides the controllers directly.

Amp-Thread-ID: https://ampcode.com/threads/T-019cbf49-a8fa-739b-9d02-f3f3eab982f4
Co-authored-by: Amp <amp@ampcode.com>
@HamptonMakes HamptonMakes merged commit 7015433 into main Mar 6, 2026
4 checks passed
@HamptonMakes HamptonMakes deleted the hampton/namespace-stimulus-controllers branch March 6, 2026 20:57
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