Scroll element into view in headless firefox browser

Hi,

PFB my code. The element is scrolled into view without any issues in normal chrome browser. But I am facing problems when using headless firefox browser.

Code:
${list_items}= get webelements //ul[@class=‘menu’]//li//p
FOR ${i} IN @{list_items}
scroll element into view ${i}
wait until element is visible ${i}
${msg}= get text ${i}
log ${msg}
END

Logs:

Log for an element which is already in the view where text is fetched. Also, Log for an element which fails to scroll in the view where text is blank,

Thanks in advance