From a1cdf551b5579e032bb51b1858013896faf7d9a1 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 2 Jun 2023 13:01:16 +0100 Subject: [PATCH] Use jQuery fake events for sticky header edit buttons The native ones do not trigger the VE code. Partially reverts I5f4464e5bfa. Bug: T336639 Change-Id: Ie088ddb7f73a2ed0b3b830fc28336d93e41c4ce5 --- resources/skins.vector.js/stickyHeader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/skins.vector.js/stickyHeader.js b/resources/skins.vector.js/stickyHeader.js index 3c8f1d95a..fccc04f5a 100644 --- a/resources/skins.vector.js/stickyHeader.js +++ b/resources/skins.vector.js/stickyHeader.js @@ -290,12 +290,12 @@ function prepareEditIcons( const $ve = $( primaryEdit ); if ( target && $ve.length ) { const link = /** @type {HTMLAnchorElement} */( $ve[ 0 ] ); - const event = new Event( 'click' ); + const event = $.Event( 'click' ); suffixStickyHref( link ); - link.dispatchEvent( event ); + $ve.trigger( event ); unsuffixStickyHref( link ); // The link has been progressively enhanced. - if ( event.defaultPrevented ) { + if ( event.isDefaultPrevented() ) { disableStickyHeader(); ev.preventDefault(); } @@ -310,12 +310,12 @@ function prepareEditIcons( const $edit = $( secondaryEdit ); if ( $edit.length ) { const link = /** @type {HTMLAnchorElement} */( $edit[ 0 ] ); - const event = new Event( 'click' ); + const event = $.Event( 'click' ); suffixStickyHref( link ); - link.dispatchEvent( event ); + $edit.trigger( event ); unsuffixStickyHref( link ); // The link has been progressively enhanced. - if ( event.defaultPrevented ) { + if ( event.isDefaultPrevented() ) { disableStickyHeader(); ev.preventDefault(); }