@@ -2,7 +2,7 @@ import '@github/markdown-toolbar-element';
2
2
import '@github/text-expander-element' ;
3
3
import $ from 'jquery' ;
4
4
import { attachTribute } from '../tribute.js' ;
5
- import { hideElem , showElem , autosize , isVisible } from '../../utils/dom.js' ;
5
+ import { hideElem , showElem , autosize , isElemVisible } from '../../utils/dom.js' ;
6
6
import { initEasyMDEImagePaste , initTextareaImagePaste } from './ImagePaste.js' ;
7
7
import { handleGlobalEnterQuickSubmit } from './QuickSubmit.js' ;
8
8
import { renderPreviewPanelContent } from '../repo-editor.js' ;
@@ -21,11 +21,12 @@ export function validateTextareaNonEmpty(textarea) {
21
21
// When using EasyMDE, the original edit area HTML element is hidden, breaking HTML5 input validation.
22
22
// The workaround (https://github.com/sparksuite/simplemde-markdown-editor/issues/324) doesn't work with contenteditable, so we just show an alert.
23
23
if ( ! textarea . value ) {
24
- if ( isVisible ( textarea ) ) {
25
- textarea . setAttribute ( ' required' , ' true' ) ;
24
+ if ( isElemVisible ( textarea ) ) {
25
+ textarea . required = true ;
26
26
const form = textarea . closest ( 'form' ) ;
27
27
form ?. reportValidity ( ) ;
28
28
} else {
29
+ // The alert won't hurt users too much, because we are dropping the EasyMDE and the check only occurs in a few places.
29
30
showErrorToast ( 'Require non-empty content' ) ;
30
31
}
31
32
return false ;
0 commit comments