As the title says, the isSidebarFitsViewport function doesn't take into consideration the top spacing.
I've updated the function to be like this:
isSidebarFitsViewport(){ return this.dimensions.sidebarHeight + this.dimensions.topSpacing < this.dimensions.viewportHeight; }
It might want to take into consideration bottom spacing though as well.