Merge "Use dispatchEvent instead of jQuery triggerHandler for focus/blur events"

This commit is contained in:
jenkins-bot 2024-08-14 23:10:56 +00:00 committed by Gerrit Code Review
commit 61d71a5f53
2 changed files with 8 additions and 4 deletions

View file

@ -125,8 +125,12 @@ class CodeMirror {
this.dirExtension,
EditorState.readOnly.of( this.readOnly ),
EditorView.domEventHandlers( {
blur: () => this.$textarea.triggerHandler( 'blur' ),
focus: () => this.$textarea.triggerHandler( 'focus' )
blur: () => {
this.$textarea[ 0 ].dispatchEvent( new Event( 'blur' ) );
},
focus: () => {
this.$textarea[ 0 ].dispatchEvent( new Event( 'focus' ) );
}
} ),
EditorView.lineWrapping,
keymap.of( [

View file

@ -191,10 +191,10 @@ function init() {
const $codeMirror = $( codeMirror.getWrapperElement() );
codeMirror.on( 'focus', () => {
$textbox1.triggerHandler( 'focus' );
$textbox1[ 0 ].dispatchEvent( new Event( 'focus' ) );
} );
codeMirror.on( 'blur', () => {
$textbox1.triggerHandler( 'blur' );
$textbox1[ 0 ].dispatchEvent( new Event( 'blur' ) );
} );
mw.hook( 'editRecovery.loadEnd' ).add( ( data ) => {
codeMirror.on( 'change', data.fieldChangeHandler );