From cdb6379d383852f713265d13d714fb548ccd0ed1 Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Tue, 23 Apr 2024 01:08:03 -0700 Subject: [PATCH] hide submit button if no comment typed in (#328) fix #105 --- src/modules/submissions.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 7d2d6a7d..6a0e15e5 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -2122,9 +2122,22 @@ function showCommentOptions() { loadView( 'comment', {} ); + + var $submitButton = $( '#afchSubmitForm' ); + $submitButton.hide(); + $( '#commentText' ).on( 'keyup', mw.util.debounce( 500, function () { previewComment( $( '#commentText' ), $( '#commentPreview' ) ); + + // Hide the submit button if there is no comment typed in + var comment = $( '#commentText' ).val(); + if ( comment.length > 0 ) { + $submitButton.show(); + } else { + $submitButton.hide(); + } } ) ); + addFormSubmitHandler( handleComment ); }