Skip to content

[Bug Fix] Accordion: sync docs Stimulus controller with gem - #490

Merged
cirdes merged 1 commit into
mainfrom
fix/accordion-docs-stale-controller
Jul 28, 2026
Merged

[Bug Fix] Accordion: sync docs Stimulus controller with gem#490
cirdes merged 1 commit into
mainfrom
fix/accordion-docs-stale-controller

Conversation

@djalmaaraujo

@djalmaaraujodjalmaaraujo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes#489

Summary

  • The gem's accordion controller was fixed in 0897b2a to toggle the hidden attribute on the content element in sync with the height animation.
  • docs/app/javascript/controllers/ruby_ui/accordion_controller.js is a separate copy (docs bundles its own JS controllers) that was never updated after that fix, so the live preview at rubyui.com/docs/accordion never opened when clicked.
  • Copied the gem's controller verbatim into the docs copy — confirmed byte-identical with diff.

The Accordion component in the gem itself was already correct; no gem changes needed.

Test plan

  • Reproduced the bug on production (rubyui.com/docs/accordion): clicking a trigger did nothing.
  • diff gem/lib/ruby_ui/accordion/accordion_controller.js docs/app/javascript/controllers/ruby_ui/accordion_controller.js → identical.
  • Rebuilt docs assets (pnpm build) locally in the docs devcontainer, ran the Rails dev server, and manually verified in browser: trigger now opens (content reveals, chevron rotates) and closes (content hides, chevron resets) correctly.

Summary by cubic

Sync the docs accordion Stimulus controller with the gem so accordion previews open and close correctly. Fixes#489.

  • Bug Fixes
    • Replaced the docs controller with the gem version to toggle the hidden attribute in sync with the height animation.
    • Removes hidden before measuring height and re-applies it after the close animation to avoid layout/focus issues.

Written for commit c989ae6. Summary will update on new commits.

Review in cubic

The docs app's copy of the accordion controller was never updated when
the gem fixed hidden-content handling in 0897b2a, so
https://rubyui.com/docs/accordion's own preview never opened — clicking
a trigger did nothing since the content stayed `hidden` regardless of
height animation. The gem component itself was already correct.

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@cirdes
cirdes merged commit 3c0f35c into mainJul 28, 2026
8 checks passed
@cirdes
cirdes deleted the fix/accordion-docs-stale-controller branch July 28, 2026 12:47
djalmaaraujo added a commit that referenced this pull request Jul 31, 2026
…d of copying
docs/app/javascript/controllers/ruby_ui/*_controller.js was a hand-maintained
copy of gem/lib/ruby_ui/<component>/*_controller.js. The two silently drifted:
the gem's accordion fix (0897b2a) never landed in the docs copy, breaking the
live accordion preview. Replace all 37 copies with relative symlinks into the
gem source, matching how docs already autoloads Phlex components straight
from gem/ (config/initializers/ruby_ui.rb) with no copy step.
- accordion_controller.js, avatar_controller.js, combobox_controller.js, and
sheet_controller.js had genuinely stale docs content pre-migration (beyond
just accordion) - the symlink now serves the gem's current, correct version.
- esbuild's default symlink handling resolves module imports relative to the
symlink's real (gem/) path, which breaks node_modules resolution since gem/
and docs/ are siblings with no shared ancestor node_modules. Build with
--preserve-symlinks so imports resolve against the symlink location instead.
- Add `rake ruby_ui:sync_controller_symlinks` (docs/lib/tasks/ruby_ui.rake):
scans gem/lib/ruby_ui for *_controller.js and creates/repairs the matching
symlink. Idempotent. Replaces the old "copy the file by hand" step for new
components; stimulus:manifest:update is still required separately to
register a brand-new controller in the manifest.
- Update CLAUDE.md, docs/CLAUDE.md, gem/AGENTS.md, and the ruby-ui-stimulus
skill to describe the symlink relationship and new workflow.
Rebased onto main after PR #490 and PR #495 merged. Both edited a docs
controller copy that this branch replaces with a symlink (accordion, popover),
so both conflicted as modify/delete. Resolved in favour of the symlink: on
main the docs copy and the gem source are byte-identical for each of the two,
so pointing at the gem loses neither fix, and #490's docs-side change becomes
moot now that the file is a symlink.
djalmaaraujo added a commit that referenced this pull request Aug 5, 2026
…d of copying
docs/app/javascript/controllers/ruby_ui/*_controller.js was a hand-maintained
copy of gem/lib/ruby_ui/<component>/*_controller.js. The two silently drifted:
the gem's accordion fix (0897b2a) never landed in the docs copy, breaking the
live accordion preview. Replace all 37 copies with relative symlinks into the
gem source, matching how docs already autoloads Phlex components straight
from gem/ (config/initializers/ruby_ui.rb) with no copy step.
- accordion_controller.js, avatar_controller.js, combobox_controller.js, and
sheet_controller.js had genuinely stale docs content pre-migration (beyond
just accordion) - the symlink now serves the gem's current, correct version.
- esbuild's default symlink handling resolves module imports relative to the
symlink's real (gem/) path, which breaks node_modules resolution since gem/
and docs/ are siblings with no shared ancestor node_modules. Build with
--preserve-symlinks so imports resolve against the symlink location instead.
- Add `rake ruby_ui:sync_controller_symlinks` (docs/lib/tasks/ruby_ui.rake):
scans gem/lib/ruby_ui for *_controller.js and creates/repairs the matching
symlink. Idempotent. Replaces the old "copy the file by hand" step for new
components; stimulus:manifest:update is still required separately to
register a brand-new controller in the manifest.
- Update CLAUDE.md, docs/CLAUDE.md, gem/AGENTS.md, and the ruby-ui-stimulus
skill to describe the symlink relationship and new workflow.
Rebased onto main after PR #490 and PR #495 merged. Both edited a docs
controller copy that this branch replaces with a symlink (accordion, popover),
so both conflicted as modify/delete. Resolved in favour of the symlink: on
main the docs copy and the gem source are byte-identical for each of the two,
so pointing at the gem loses neither fix, and #490's docs-side change becomes
moot now that the file is a symlink.
djalmaaraujo added a commit that referenced this pull request Aug 5, 2026
…d of copying (#493)
* [Improvement] Docs: symlink Stimulus controllers to gem source instead of copying
docs/app/javascript/controllers/ruby_ui/*_controller.js was a hand-maintained
copy of gem/lib/ruby_ui/<component>/*_controller.js. The two silently drifted:
the gem's accordion fix (0897b2a) never landed in the docs copy, breaking the
live accordion preview. Replace all 37 copies with relative symlinks into the
gem source, matching how docs already autoloads Phlex components straight
from gem/ (config/initializers/ruby_ui.rb) with no copy step.
- accordion_controller.js, avatar_controller.js, combobox_controller.js, and
sheet_controller.js had genuinely stale docs content pre-migration (beyond
just accordion) - the symlink now serves the gem's current, correct version.
- esbuild's default symlink handling resolves module imports relative to the
symlink's real (gem/) path, which breaks node_modules resolution since gem/
and docs/ are siblings with no shared ancestor node_modules. Build with
--preserve-symlinks so imports resolve against the symlink location instead.
- Add `rake ruby_ui:sync_controller_symlinks` (docs/lib/tasks/ruby_ui.rake):
scans gem/lib/ruby_ui for *_controller.js and creates/repairs the matching
symlink. Idempotent. Replaces the old "copy the file by hand" step for new
components; stimulus:manifest:update is still required separately to
register a brand-new controller in the manifest.
- Update CLAUDE.md, docs/CLAUDE.md, gem/AGENTS.md, and the ruby-ui-stimulus
skill to describe the symlink relationship and new workflow.
Rebased onto main after PR #490 and PR #495 merged. Both edited a docs
controller copy that this branch replaces with a symlink (accordion, popover),
so both conflicted as modify/delete. Resolved in favour of the symlink: on
main the docs copy and the gem source are byte-identical for each of the two,
so pointing at the gem loses neither fix, and #490's docs-side change becomes
moot now that the file is a symlink.
* [Improvement] Docs: abort symlink sync on duplicate controller basenames
Address cubic review on #493:
- `ruby_ui:sync_controller_symlinks` now detects two gem controllers sharing a
basename before creating any link and aborts listing the offenders. The docs
controllers directory is flat, so the second symlink would silently clobber
the first and one component would ship the wrong JS.
- Fix the missing `rake` prefix on `stimulus:manifest:update` in the
ruby-ui-stimulus skill.
* fix(docs): pin node-linker=hoisted so --preserve-symlinks can build
`--preserve-symlinks` is what makes the symlinked controllers resolve their
external imports (`@hotwired/stimulus`, `motion`, `maska`, `chart.js`) against
`docs/node_modules` instead of the unreachable `gem/` real path. But it also
stops esbuild from following pnpm's *own* symlinks, so package-internal
requires break on a plain `pnpm install`:
✘ [ERROR] Could not resolve "@hotwired/turbo"
node_modules/@hotwired/turbo-rails/app/javascript/turbo/index.js:3:23
✘ [ERROR] Could not resolve "framer-motion/dom"
node_modules/motion/dist/es/index.mjs:1:14
pnpm keeps those transitive deps inside `.pnpm/<pkg>/node_modules`, reachable
only by following the symlink the flag just disabled.
`node-linker=hoisted` gives a flat `node_modules` of real directories, so the
only symlinks left in the tree are the intentional controller ones and both
halves of resolution work. Verified: `pnpm build` succeeds, the bundle carries
the gem-sourced controller code, and Stimulus is bundled exactly once (no
duplicated copy that would silently fail to register controllers).
* ci(docs): build assets so a broken bundle fails the job
The docs job installed dependencies and then went straight to standardrb and
the Rails suite, so `pnpm build` never ran in CI. A bundle that fails to
resolve its imports was invisible — which is how the `--preserve-symlinks` /
pnpm-symlink collision fixed in the previous commit got a green checkmark.
Now that a controller edit in `gem/` is what the docs site actually serves,
esbuild resolution is part of the contract this job should be checking.
@djalmaaraujodjalmaaraujo mentioned this pull request Aug 5, 2026
djalmaaraujo added a commit that referenced this pull request Aug 5, 2026
Bump RubyUI to 1.6.0 (minor: new component + new component options since v1.5.0).
- gem/lib/ruby_ui.rb → 1.6.0; regenerate gem/ and docs/ Gemfile.lock
- docs home hero badge → headline features (InputOtp, Combobox placement)
- rebuild mcp/data/registry.json
Highlights since v1.5.0:
- New component: InputOtp (#456)
- Combobox: configurable popover placement (#480), CheckboxGroup reuse for required ComboboxCheckbox (#479)
- DataTable: custom label + initial column visibility in DataTableColumnToggle (#466)
- Popover: data-state/data-side, clear closeTimeout on disconnect, close on Escape (#495)
- Accordion: no longer clips content that grows after opening (#500, #490)
- Toast: toaster state initialized in initialize() so server-rendered toasts don't throw (#499)
- Docs: Stimulus controllers symlinked to gem source, no more hand-copied drift (#493)
Sign up for freeto 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.

Accordion preview broken on rubyui.com/docs/accordion

2 participants

@djalmaaraujo@cirdes