Skip to content

Commit 3303a74

Browse files
justin808claude
andcommitted
Fix validation logic in Stimulus comments controller
Fixed bug where validation errors for both empty fields were not being displayed correctly. Changed else-if to if so both Author and Text validation errors can be added when both fields are empty. This fixes the failing Stimulus/Turbo tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent d84de80 commit 3303a74

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

client/app/controllers/comments_controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default class extends Controller {
2222
errorList.innerHTML = '';
2323
if (!inputAuthor.value) {
2424
errors.push('Author');
25-
} else if (!inputText.value) {
26-
errors.push('Text');
27-
} else {
28-
errors.push('Author');
25+
}
26+
if (!inputText.value) {
2927
errors.push('Text');
3028
}
3129
errors.forEach((error) => {

0 commit comments

Comments
 (0)