WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 21 months ago

#37536 new defect (bug)

Twenty Fifteen: Improve sticky sidebar logic.

Reported by: DvanKooten Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.1
Component: Bundled Theme Keywords: reporter-feedback
Focuses: javascript Cc:

Description

The current logic in TwentyFifteen (#30366) for making the sidebar sticky while still allowing to scroll through it when the sidebar height is larger than the viewport height is flawed and massively overcomplicated.

This results in buggy behaviour when third-party code (in plugins) add body padding, for example.

Steps to reproduce buggy behavior:

<?php
add_action( 'wp_footer', function() {
   echo "<script>document.body.style.paddingTop = '50px';</script>";
});

Basically any plugin that implements admin bar like behavior will cause problems, with the sidebar thinking it has to apply a top offset where it actually doesn't have to do anything.

This can be mitigated by removing the admin bar specific logic and leaving most of the heavy lifting up to the browser.

Attachments (3)

37536.diff (3.4 KB) - added by DvanKooten 23 months ago.
37536.2.diff (3.4 KB) - added by DvanKooten 23 months ago.
Fix non-stickiness for small sidebars.
37536.2.2.diff (3.6 KB) - added by DvanKooten 23 months ago.
Fix non-stickiness for small sidebars.

Download all attachments as: .zip

Change History (7)

@DvanKooten
23 months ago

#1 @ocean90
23 months ago

  • Version changed from trunk to 4.1

@DvanKooten
23 months ago

Fix non-stickiness for small sidebars.

@DvanKooten
23 months ago

Fix non-stickiness for small sidebars.

#2 @lukecavanagh
23 months ago

@DvanKooten

Patch applies cleanly with no issues.

#3 @karmatosed
21 months ago

@DvanKooten do you have an example of a plugin that does this? I would like to test in a real case over outputting code to footer.

#4 @karmatosed
21 months ago

  • Keywords reporter-feedback added
Note: See TracTickets for help on using tickets.