Skip to content

Commit fb50124

Browse files
justin808claude
andcommitted
Fix validation logic to show all error messages and add explicit class name
- Change validation logic from if/else chain to independent if statements This ensures both "Author" and "Text" error messages are displayed when both fields are blank, rather than just showing one error at a time - Add explicit class name CommentsController for better debugging and compatibility with future transpiler changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 577e4b5 commit fb50124

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

client/app/controllers/comments_controller.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { mangle } from 'marked-mangle';
77
marked.use(gfmHeadingId());
88
marked.use(mangle());
99

10-
export default class extends Controller {
10+
export default class CommentsController extends Controller {
1111
static targets = ['commentList', 'commentAuthor', 'commentText', 'commentRefresh', 'alertDiv', 'errorList'];
1212

1313
resetText() {
@@ -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)