Correctly hide the sticky header when it is not in use
When the vector-sticky-header-enabled class is removed from the body it means the feature is not enabled, it doesn't mean the sticky header should be invisible. Call the hide method instead, and move it out of the function given its a side effect Bug: T308343 Change-Id: I4ecd6524146f203af926847812e20275c9573cab
This commit is contained in:
parent
b8701a3b58
commit
deb54f9452
|
@ -76,13 +76,6 @@ function initStickyHeaderABTests( abConfig, isStickyHeaderFeatureAllowed, getEna
|
|||
// If running initial AB test, only show sticky header to treatment group.
|
||||
if ( stickyHeaderExperiment.name === stickyHeader.STICKY_HEADER_EXPERIMENT_NAME ) {
|
||||
show = stickyHeaderExperiment.isInTreatmentBucket();
|
||||
|
||||
// Remove class if present on the html element so that scroll
|
||||
// padding isn't applied to users who don't experience the new treatment.
|
||||
if ( !show ) {
|
||||
document.documentElement.classList.remove( 'vector-sticky-header-enabled' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If running edit-button AB test, show sticky header to all buckets
|
||||
|
@ -157,6 +150,10 @@ const main = () => {
|
|||
}
|
||||
);
|
||||
|
||||
if ( !showStickyHeader ) {
|
||||
stickyHeader.hide();
|
||||
}
|
||||
|
||||
if ( isStickyHeaderAllowed && showStickyHeader ) {
|
||||
stickyHeader.initStickyHeader( {
|
||||
header,
|
||||
|
|
|
@ -118,6 +118,10 @@ describe( 'main.js', () => {
|
|||
} )
|
||||
);
|
||||
expect( result ).toMatchObject( expectedResult );
|
||||
// Check that there are no side effects
|
||||
expect(
|
||||
document.documentElement.classList.contains( 'vector-sticky-header-enabled' )
|
||||
).toBe( true );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue