fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Scrollable Pane not returning to the initalScrollPosition when the content updates. Need a fix/workaround.

Open gottacodeemall opened this issue 6 years ago • 14 comments

Environment Information

  • Package version(s): 1.110.5 (in local)
  • Browser and OS versions: Chrome Version 81.0.4044.138 (Official Build) (64-bit)

Please provide a reproduction of the bug in a codepen:

Replication Steps - Directly replicated it on the Fluent UI example page:

https://developer.microsoft.com/en-us/fluentui#/controls/web/scrollablepane

In the 'DetailsList Locked Header' scroll down to a non zero position exceeding the first page and enter 'sed' in the 'filter by name'. This updates the detailsList and the scrollbar does not go to the initial position.

Actual behavior:

As we scroll down to let's say a position of 50 and now if there is an update to the details list with say suppose 350. The scrollbar is not returning to the starting position and it rerenders to a random position close to the top(in my case).

Tried a temporary hack:

Going through the code, I noticed that the initial scroll position of the scrollablepane is being refreshed only when the 'initialScrollPosition' props change in the implementation. I tried changing the 'initialScrollPosition' prop in my component whenever the detailList updates by setting it to either 0 or 1. Debugging this, the props for the initialScrollPosition did not change inside the ScrollablePane component did not change. This did not work and the scrollable pane is still not set to the start.

Expected behavior:

Whenever the content inside the scrollpane updates, there should be a way for the developer to set the scrollPosition of the ScrollablePane to its initial position.

Priorities and help requested:

Are you willing to submit a PR to fix? Did not find a solution. If found, then Yes.

Requested priority: Normal

Products/sites affected: (if applicable)

gottacodeemall avatar May 12 '20 06:05 gottacodeemall

@gottacodeemall Thanks for reaching out to us. I think this might be a focus problem because it doesn't let me scroll the detailslist once I enter the search term in the filter box because I think that box grabs focus. When I click on the detailslist after the filter then it lets me scroll again.

We're currently focusing on improvements to performance and coherence, as you can see in our pinned issue on the repo detailing our v8 plans. So while we don't plan to address this right now, we will take it into consideration when we schedule future work for DetailsList.

@ecraig12345 might have more insights into a workaround for this in the meantime.

aneeshack4 avatar May 12 '20 15:05 aneeshack4

@aneeshack4 You are right that when a user tires to modify the search filter, the scrollable pane cannot be manually scrolled. The issue that I raised is a bit different.

The application of the search filter results in reloading of the list inside the scrollpane (which is similar to my scenario where the user in my application clicks a link and the detailsList updates).

From a user experience standpoint, once the list updates, it is expected that the scrollpane returns to the top rather readjust according to an internal logic. There isn't any API exposed to set the scrollPosition and the problem does not revolve around DetailsList as the ScrollablePane is the parent element can listen to changes for its children.

I tried hacks around this as I mentioned above but was not successful. Any help would be appreciated.

gottacodeemall avatar May 13 '20 05:05 gottacodeemall

@aneeshack4 Any update on this??

gottacodeemall avatar May 18 '20 11:05 gottacodeemall

@leddie24 Do you have any suggestions for this?

ecraig12345 avatar May 30 '20 01:05 ecraig12345

See the same issues as above, are there any temporary workarounds?

rachitpuri95 avatar Aug 14 '20 00:08 rachitpuri95

@tharshada or @leddie24 do you have any suggestions for how to fix or work around this issue?

ecraig12345 avatar Aug 14 '20 18:08 ecraig12345

Is there any update on a possible workaround?

deagraw avatar Oct 30 '20 06:10 deagraw

Looking for a solution to this issue ?

maheshkumawat24 avatar Nov 05 '20 08:11 maheshkumawat24

wow and it still not fixed yet ? what a shame

Strypper avatar Mar 12 '21 15:03 Strypper

?

bharath3719 avatar Jul 22 '21 12:07 bharath3719

Looking for solution here too :(

Dan86de avatar Aug 25 '21 08:08 Dan86de

Looks like this works for me untill it is fixed.

useEffect(() => {
    if (scrollablePaneRef.current) {
      // eslint-disable-next-line no-underscore-dangle
      const div: HTMLDivElement = (scrollablePaneRef.current as any)._root.current;
      div.querySelector('.ms-ScrollablePane--contentContainer').scrollTop = 0;
    }
}, [items]);

ocean89 avatar Sep 10 '21 14:09 ocean89

My workaround,

const detailsListRef = React.createRef<IDetailsList>();

const resetScroll = () => {
    detailsListRef.current.scrollToIndex(0);
}
<DetailsList
    {...otherProps} 
    componentRef={detailsListRef}
/>

raj-pat avatar Sep 14 '21 18:09 raj-pat

Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Mar 13 '22 19:03 msft-fluent-ui-bot