bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

refreshOptions causes the page to scroll to top

Open dougauerbach opened this issue 3 years ago • 4 comments

Bootstraptable version(s) affected: 1.8.3

Description
I have a bootstrap-table configuration which combines refeshOptions with pagination. As a result, when displaying a table that is down the page, then clicking a page in the pagination toolbar will trigger a reload of the data along with refreshOptions. When refreshOptions executes, the page scrolls to the top. (User impact is that you must scroll back down to find the pagination toolbar to select a different page. Also the display seems jarring.)

Example
https://live.bootstrap-table.com/code/dougauerbach/7491

Possible (optional)
if this is required in certain scenarios, perhaps an enhancement would be to add an option to disable the scrollToTop behavior.

dougauerbach avatar Apr 23 '21 08:04 dougauerbach

Mark as feature since this is working as designed.

djhvscf avatar Apr 24 '21 21:04 djhvscf

Workaround example: https://live.bootstrap-table.com/code/wenzhixin/7510 I don't think it's a feature.

wenzhixin avatar Apr 25 '21 14:04 wenzhixin

@wenzhixin i guess @djhvscf means we should add the feature/functionality that we stay on correct position.

UtechtDustin avatar Apr 25 '21 15:04 UtechtDustin

Not sure if I should create a new issue or respond here but this issue is still open, so:

Workaround example: https://live.bootstrap-table.com/code/wenzhixin/7510 I don't think it's a feature.

The workaround proposed does not work with onPostBody (using local data) and Bootstrap 5: https://live.bootstrap-table.com/code/realraec/10338

I used the refreshOptions method to enable/disable buttons in the buttonbar, so I added a dummy button to the example used before -- I also changed the way the table fetches data (locally, not from a url). In the example, go to "Libraries" and change the "Theme" to see that the workaround works with Bootstrap 4 and previous versions (but not with Bootstrap 5) -- I don't think the "going back to the top" thing should be a feature either, but regardless, there should definitely at least be a workaround that works.

(Note that in a similar context in my own project, the workaround is extremely buggy when used together with the "filter control" extension, since for some reason it fires the onPostBody event DOZENS of times, making the workaround take 1-2 second(s) and visibly move back down every time, plus if the pagination is on, it brings the table back to page 1 every time. All that is to say, there is an extra reason why the workaround is not viable.)

EDIT 02/16: The workaround seems to work now. The problem with FilterControl is still very real, though.

realraec avatar Jan 21 '22 21:01 realraec