primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Lazy loading is not triggered on filter input change in Dropdown

Open paveldayneko opened this issue 3 years ago • 8 comments

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case

https://codesandbox.io/s/mystifying-bhaskara-v2twz?file=/src/demo/DropdownDemo.js

Current behavior Filter input does not trigger virtual load

Expected behavior onLazyLoad callback should be called on filter input change

Minimal reproduction of the problem with instructions

  • Create virual scroll dropdown with lazy load
  • Add filter
  • Try to type some text in filter's input
  • Nothing happens
  • PrimeReact version: 7.1.0 and 7.2.0

  • Browser: [Chrome]

  • Language: [all]

paveldayneko avatar Jan 25 '22 10:01 paveldayneko

i'm having the same problem, i tried to force a solution by calling the "onFilter" method with the same "onlazyload" property call.. and it didn't work either :/

Catstein avatar Apr 27 '22 12:04 Catstein

Yep right now it looks like the only thing filter is doing is setting the scroll index of lazy list back to 0.

    const onFilterInputChange = (event) => {
        virtualScrollerRef.current && virtualScrollerRef.current.scrollToIndex(0);

        props.onFilterInputChange && props.onFilterInputChange(event);
    }

melloware avatar Apr 27 '22 13:04 melloware

it's also happening with me, i've tried several things but i cant make it work :c

vinirossa avatar May 02 '22 19:05 vinirossa

so are there any workarounds recommended? what does invoke the onlazyload fn? maby its possible to mock a trigger event

dani-ras avatar Aug 25 '22 09:08 dani-ras

I think it needs to be fixed in the component I just don't know what to fix it to.

melloware avatar Aug 25 '22 11:08 melloware

Hello budy, how are you?

I come to propose an alternative way of using dropdown with an asynchronous filter. Here's the proposal, I hope it helps you: Live code

jonmferreira avatar Sep 12 '23 21:09 jonmferreira

Hi guys! I am facing the same problem, did something of a workaround with a hardcoded non-clickable itemTemplate. Hope this gets fixed soon...

yabelozub avatar Nov 14 '23 14:11 yabelozub

Hi, having the same issue. My workaround:

onFilter={() => {
      const scrollerRef: HTMLElement | null = document.querySelector('.p-virtualscroller-content');
      if (scrollerRef?.style?.transform) {
        scrollerRef.style.transform = 'translate3d(0px, 0px, 0px)';
      }
    }
}

DieterMorar avatar Feb 15 '24 10:02 DieterMorar