From c634608057efa819ba0092b0974a777c1f92b252 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Wed, 29 Nov 2023 12:50:34 +0100 Subject: [PATCH] Add fail-safe to SliderView.revisionsClickHandler Turns out we can run into this failure situation even if everything goes according to plan. It is possible to click just one pixel outside of the valid range, e.g. on the very right corner right next to the last bar. This is supposed to not do anything anyway, and correctly doesn't do anything from the user's perspective. But it shows up as a failure in the JavaScript console. Bug: T352169 Change-Id: I12c9cce90970be36667ba1b721afd38a13a063c9 --- modules/ext.RevisionSlider.SliderView.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ext.RevisionSlider.SliderView.js b/modules/ext.RevisionSlider.SliderView.js index 2fa36bc2..bf05eff6 100644 --- a/modules/ext.RevisionSlider.SliderView.js +++ b/modules/ext.RevisionSlider.SliderView.js @@ -315,8 +315,12 @@ $.extend( SliderView.prototype, { */ revisionsClickHandler: function ( event ) { const clickedPos = this.getRevisionPositionFromLeftOffset( event.pageX ), - $revisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), clickedPos ).parent(), - hasClickedTop = event.pageY - $revisionWrapper.offset().top < $revisionWrapper.height() / 2; + $revisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), clickedPos ).parent(); + // Fail-safe in case a mouse click outside the valid range is picked up + if ( !$revisionWrapper.length ) { + return; + } + const hasClickedTop = event.pageY - $revisionWrapper.offset().top < $revisionWrapper.height() / 2; let newNewerPointerPos, newOlderPointerPos; if ( hasClickedTop &&