SOLVED

In SPFX header/footer extensions, can I make footer scroll down along the main content of the page

Copper Contributor

I am using react SharePoint Framework Extensions to create my header and footer for the site. Right now the footer is fixed, as it will stay on the page even if you scroll down the content. As my footer have good number of links, so in this case it will consume some space on the screen and will not go away.

I want to make the footer scroll with the content, if the page have more data in it then the footer should be at the bottom after the main content.

 

Is this possible ? please suggest

9 Replies
best response confirmed by TarundeepSinghTheta (Copper Contributor)
Solution
If you want to achieve scroll-able footer SPFX header/footer extensions will not be a good idea as the SPFX footer extension has fixed positioning over the scroll-able area

Please have look at the conversation.

https://github.com/SharePoint/sp-dev-docs/issues/785

Hope this helps,
Thuyavan

Thanks for that Thuyavan. That was helpful. 🙂 

I am not planing to make it a click open and close footer menu instead. Is there any other way I can achieve this.

Thanks in advance. 

@TarundeepSinghTheta Hi, Did u overcame this issue? I have a similar issue where Header and Footer created through SPFx occupies most of the page. Any luck with CSS or scrollable event?

@spfx-123_new1240 

Hi,

The footer in SPFX extension have fixed positioning so its not possible for now to make if scroll able.

If you want it to be scroll able then you can add it in a web part and always keep that one the last web part on the page. But before that you need to hide all elements of the actual footer. 
The other way around which I can think is to create a SPFX extension but make the footer hidden when user scrolls down. It might be tricky to manage the CSS.

 

Regards,

@Tarundeep 

 

Hi,

 

I want to make the footer availiable inside the scroll bar, did anybody find any solution to this?

Please let me know

This thread is old, but this is still an issue due to the standard footer limitations.

I overcome this by creating an empty bottom placeholder to use its navigated events.
Created my react footer element in a const.
If the placeholder and its domElement exists, I add a scroll event to window to replace the standardfooter (html footer tag) using limited recursive tries to get it, as soon as its gotten, I use ReactDOM.hydrate with my element, but could be render.

Hope this helps somebody.

@Diego_Longhi  Can you please share reference URL or implementation code snippets here ? 

@TarundeepSinghTheta Please let me know the response. I'm also stuck at the same point 

this is not "the supported way of doing things", it can break anytime as ms updates the layout structure, so use at your own risk. This is not the entire code, so probably you will have to edit it to work, but will help.

const reactElement = = React.createElement( ); const mainContent = document.querySelector('[role="main"]'); mainContent.addEventListener('scroll', (event) => { if ((event.currentTarget as unknown as HTMLElement).getAttribute("role") === "main") { const currentDiv = (event.currentTarget as HTMLDivElement); if ((currentDiv.scrollTop + 100) >= currentDiv.scrollHeight - currentDiv.offsetHeight - currentDiv.offsetTop) { if (this.footerRenderTries === 0 && window['footerRendered'] === false) { this.replaceStandardFooter(); } else { const standardFooter = document.querySelector('[data-automationid="MegaFooter"]'); if (typeof standardFooter !== 'undefined' && standardFooter) { standardFooter.remove(); } } } } }); const replaceStandardFooter = (): void => { try { this.footerRenderTries = this.footerRenderTries + 1; const standardFooter = document.getElementsByTagName('footer'); ReactDOM.render(reactElement, standardFooter[0]); window['footerRendered'] = true; } catch (erroFooter) { if (this.footerRenderTries <= 20) { console.error(); await delay(1000); this.replaceStandardFooter(); } else { console.error(); this.footerRenderTries = 0; } } }
1 best response

Accepted Solutions
best response confirmed by TarundeepSinghTheta (Copper Contributor)
Solution
If you want to achieve scroll-able footer SPFX header/footer extensions will not be a good idea as the SPFX footer extension has fixed positioning over the scroll-able area

Please have look at the conversation.

https://github.com/SharePoint/sp-dev-docs/issues/785

Hope this helps,
Thuyavan

View solution in original post