Manually expand any section containing a highlight

Bug: T336190
Change-Id: Ia0d46dad8f98c3f364bc1c378ab25f745e642f86
This commit is contained in:
Ed Sanders 2023-08-17 13:25:03 +01:00
parent 6d4eb2e87b
commit b33cafe0cd

View file

@ -27,7 +27,7 @@ function Highlight( comments ) {
// when it shifts (e.g. collapsing the table of contents), and disappears when it is hidden (e.g.
// opening visual editor).
var range = comment.getNativeRange();
// Support: Firefox, IE 11
// Support: Firefox
// The highlight node must be inserted after the start marker node (data-mw-comment-start), not
// before, otherwise Node#getBoundingClientRect() returns wrong results.
range.insertNode( $highlight[ 0 ] );
@ -60,6 +60,15 @@ function Highlight( comments ) {
this.updateDebounced = OO.ui.debounce( this.update.bind( this ), 500 );
window.addEventListener( 'resize', this.updateDebounced );
if ( OO.ui.isMobile() ) {
// In MobileFrontend, ensure the section we are highlighting within is expanded. This is
// often the case as we add the hash fragment to our notification URLs, but not when we highlight
// comments across multiple threads.
// HACK: Ideally MF would expose Toggler as a public API, but for now just find the correct DOM
// node and trigger a fake click.
this.$element.parents( '.collapsible-block' ).prev( '.collapsible-heading:not( .open-block )' ).trigger( 'click' );
}
this.update();
}