Sticky header: Wait for some repainting to happen after VE teardown

Waiting for one animation frame seems to make the sticky header
re-appear consistently.

Bug: T299114
Change-Id: Ie1230bf861f12e4e18a6adb0f6779c199d6954a1
This commit is contained in:
Ed Sanders 2022-01-14 14:41:36 +00:00
parent 591e1d296c
commit da1fb74554
1 changed files with 5 additions and 1 deletions

View File

@ -319,7 +319,11 @@ function addVisualEditorHooks( targetIntersection, observer ) {
// When Visual Editor is deactivated (by clicking "Read" tab at top of page), show sticky header
// by re-triggering the observer.
mw.hook( 've.deactivationComplete' ).add( () => {
observer.observe( targetIntersection );
// Wait for the next repaint or we might calculate that
// sticky header should not be visible (T299114)
requestAnimationFrame( () => {
observer.observe( targetIntersection );
} );
} );
// After saving edits, re-apply the sticky header if the target is not in the viewport.