question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PrimeFaces.scrollTo

See original GitHub issue

Describe the bug

After one of the latest Firefox and Chrome updates

PrimeFaces.scrollTo() in not scrolling anymore

Reproducer


<p:panel id="data" style="height: 1000px;">
  Hello
</p:panel>

<!-- works -->
<a href="#" onclick="window.scrollTo(0,0)" >Scroll JS</a>  

<!-- does nothing -->
<a href="#" onclick="PrimeFaces.scrollTo('data');" >Scroll JS PrimeFaces</a>  

<!-- does nothing -->
<h:form id="test">
    <p:commandButton id="scroll" action="#{testAction.scrollTo('data')}" value="Scroll Ajax PrimeFaces" /> 
</h:form>
@Named
@ViewScoped
public class TestAction implements Serializable {
    private static final long serialVersionUID = 819314778934153831L;
    
    public void scrollTo(String id) {
      PrimeFaces.current().scrollTo(id);
    }
}

Expected behavior

scroll to “data” p:panel

PrimeFaces edition

Elite

PrimeFaces version

8.0.17

Theme

No response

JSF implementation

Mojarra

JSF version

2.2.20

Browser(s)

Chrome 102 | Firefox 100 - Fedora 35 | Windows 11

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Jun 1, 2022

PF code is doing this which is what a lot of users in that Stack Overflow recommend to do…

            $('html,body').animate({
                scrollTop:offset.top,
                scrollLeft:offset.left
            },{
                easing: 'easeInCirc'
            },1000);
            
1reaction
pizzi80commented, Jun 1, 2022

tested, it works…

the problem is css smooth scroll

If you enable it inside test.css

html { scroll-behavior: smooth; }

PrimeFaces.scrollTo does not work anymore

I don’t know why but before Chrome 102 or 101 and FF 100 or 99 it was working for sure, because i use this technique since 2 years

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScrollTo a Component After Ajax Update - PrimeFaces
When the panel component is updated, PrimeFaces will scroll to the component with a smooth animation. Check out the live demo at PrimeFaces...
Read more >
Primefaces RequestContext scrollTo does not work
Primefaces v3.5. Trying to use RequestContext.getContext().scrollTo("") to scroll to my form programmatically at the end of an ajax request.
Read more >
RequestContext (primefaces 6.2 API) - javadoc.io
Use PrimeFaces.scrollTo(java.lang.String) instead. static void, setCurrentInstance​(RequestContext context, javax.faces.context.FacesContext facesContext).
Read more >
ScrollTop | PrimeFaces JavaScript API Docs
Class ScrollTop<TCfg>. PrimeFaces ScrollTop Widget. ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page ......
Read more >
PrimeFaces.executeScript - Java - Tabnine
public void scrollTo(String clientId) { executeScript("PrimeFaces.scrollTo('" + clientId + "');");
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found