HOLD: Audit Stimulus controllers for conventions (split into smaller pr's)#1392
HOLD: Audit Stimulus controllers for conventions (split into smaller pr's)#1392
Conversation
|
@jmilljr24 how does this look? |
jmilljr24
left a comment
There was a problem hiding this comment.
I think there is too much in this for me to feel confident about the changes. I gave a couple of examples where things just didn't make sense. There is definitely some value within these changes but there needs to be quite a bit more manual validation.
Some of the clean up (remove unused controller or case conventions) seem fine. Anything else I'd rather do in smaller PR's with some more attention and user testing. Maybe update a controller if a feature being worked on involves it.
| if (type === "checkbox") { | ||
| this.toggleClass(event.target); | ||
| } | ||
| handleChange(event) { |
There was a problem hiding this comment.
By creating this function, this change essential us just duplicating what was already in the connect function but now requires added a stimulus action in the html (extra code). By using connect which is built in to stimulus, the code automatically runs once the stimulus element is connected. Thats what this.element is.
There is other additional code additions in this controller that don't seem necessary. (target.type === "search" ?)
There was a problem hiding this comment.
These seem fine as they are part of the conversation we had.
| this.processPayload(event.params.payload); | ||
| this.manageEventListeners(); | ||
| this.open = !this.open; | ||
| this.openValue = !this.openValue; |
There was a problem hiding this comment.
Stimulus values are used to track or update a value in the dom. this.open is simply an instance variable/property we are using to keep track of the state. We don't need an actual value in the dom, the js controller instance itself can can track it.
| import { Controller } from "@hotwired/stimulus"; | ||
| import TomSelect from "tom-select"; | ||
|
|
||
| const styleId = "remote-select-overrides"; |
There was a problem hiding this comment.
I don't see why this is needed.
| <%= form_with url: url, | ||
| method: :get, | ||
| data: { controller: "collection", | ||
| action: "change->collection#handleChange input->collection#handleInput", |
There was a problem hiding this comment.
| action: "change->collection#handleChange input->collection#handleInput", | |
We get this for free with stimulus if we keep the logic in the connect function.
- Remove dead controllers (nav, search_box) - Convert querySelector/getElementById to static targets - Convert instance variables to static values - Replace addEventListener with data-action attributes - Replace style.display with hidden class toggling - Fix CSS injection leak in remote_select - Remove console.log statements - Add comprehensive Stimulus conventions to AI instruction files - Add AI Instruction Files reference table to CLAUDE.md - Update PR instruction wording to "content" (covers checklists) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- tag_deduping.rake no longer exists, remove from AGENTS.md - Add instruction to update AI files on every push when conventions, architecture, or file lists change Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- copilot-instructions.md now just points to CLAUDE.md and AGENTS.md - AGENTS.md removes duplicated PR, Git, and frontend preference sections - CLAUDE.md updated to reflect the new structure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CLAUDE.md should be lean — only coding rules and conventions that need to be in every conversation context. Project overview, tech stack, setup, key directories, testing details, linting/security commands all moved to AGENTS.md where agents can look them up on demand. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot inline suggestions can't follow file references, so it needs its own copy of code style, RuboCop, Stimulus, and HTML/ERB rules. Without these, Copilot suggestions regularly fail RuboCop CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rake tasks: 17 → 4 (removed nonexistent paperclip_to_active_storage) - Services: 15 → 21 (added event_registration, user, and other services) - Stimulus controllers: 20 listed → all 34 listed - Model concerns: added AuthorCreditable - Controller concerns: added TagAssignable - Updated all directory and spec counts to match actual codebase - Jobs: 2 → 3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
List the exact things to check: Stimulus controllers, services, concerns, mailers, rake tasks, and file counts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add convention to AI files and rename existing constants: STYLE_ID → styleId, ACTIVE_CLASSES → activeClasses, GRAY_CLASSES → grayClasses, HIGHLIGHT_CLASS → highlightClass, FILE_TYPE_ICONS → fileTypeIcons Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prefer Font Awesome free icons over inline SVGs by default. Inline SVGs still allowed when a specific icon design is preferred. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep the full name in the project overview, use "this codebase" elsewhere to avoid hardcoding the name throughout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- events_spec: update data-column-toggle-col to data-column-toggle-target="col" - password_field_toggle_spec: scope toggle click within controller wrapper and use eventually matcher for async type change Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The collection controller was refactored to use data-action instead of addEventListener, but only video_recordings was updated. All 17 other forms using the collection controller were missing the action attributes, breaking search/filter auto-submit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- collection_controller: Keep addEventListener in connect() — idiomatic when listening on the controller's root element, avoids data-action attributes in 18 views - dropdown_controller: Use this.open instance property instead of Stimulus value — values are for DOM-reflected state, not internal tracking - remote_select_controller: Remove styleId guard — unnecessary abstraction - paginated_fields_controller: Use this.currentPage instance property - comment_edit_toggle_controller: Use this.editing instance property Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
acd06a5 to
a5cad9a
Compare
- addEventListener in connect() is fine for root-element events - Use instance properties for internal state, not static values - Don't add guards without evidence of a bug Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
querySelector/ direct DOM querieshiddenclass instead of inlinestyle.displaymanipulationSCREAMING_SNAKE_CASEtocamelCasenav,search_box)console.logstatementsTest plan
Column toggle (events manage)
Comment edit toggle
Dirty form (unsaved changes warning)
Password toggle (eye icon)
Tabs controller
Paginated fields
Tags combination highlight
Print options
Toggle lock controller
hiddenclassToggle user icon controller
Removed controllers
data-controller="nav"ordata-controller="search-box"🤖 Generated with Claude Code