Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focusing/scroll issues when virtualization is enabled #424

Closed
cetetesoft opened this issue Jul 6, 2024 · 4 comments
Closed

Focusing/scroll issues when virtualization is enabled #424

cetetesoft opened this issue Jul 6, 2024 · 4 comments
Assignees

Comments

@cetetesoft
Copy link

Hi.

I have one bug report and one enhancement suggestion regarding the scrolling behavior for virtualized rows.

When calling table.moveFocusedUp(), if the current cell is on top (ie from the 1st visible row), the table wrapper won't scroll up. This behavior is different from that of table.moveFocusedDown() for the last visible cell. In addition, the cell keeps the :focus-within style, even though I can tell it's not actually the active cell.

Steps to reproduce:

  1. You'll need a sample table combining keyboard navigation and virtualization.
  2. Move the table down so that the first visible row is not the first row of data. There will be some rows above that one (ie an empty <tr> with the height attribute).
  3. Select a cell from the first row.
  4. Press the ArrowUp key several times.
  5. Press the ArrowDown key several times. You'll need to press it as many times as ArrowUp.

Additionally, it would be nice for the scroll down behavior to more consistent. Right now, if you press ArrowDown having the last visible row selected, it will scroll the table by one row only if the last row is completely visible. When that row is partially visible, however, the table will scroll by about 50% of the visible height. Could this be customized in some way, like, scrolling just one row in all cases (like spreadsheet software such as Excel does)?

Thanks.

@komarovalexander
Copy link
Owner

komarovalexander commented Jul 9, 2024

HI @cetetesoft
Can I ask you to provide stackblitz example with described behavior https://stackblitz.com/edit/table-many-rows-ts?file=Demo.tsx ?

@komarovalexander komarovalexander self-assigned this Jul 9, 2024
@cetetesoft
Copy link
Author

Sure, @komarovalexander . Here you are:
https://stackblitz.com/edit/table-many-rows-ts-8seuhl?file=Demo.tsx

The demo will start with the cell (1;10) selected. The visible rows are 0 through 11. After pressing ArrowDown twice, the table wrapper will scroll down, showing rows 7 to 18. Regarding this behavior, could it be changed somehow to scroll by one row - ie showing rows 1 to 12, then 2 to 13, and so on?

Now, from this point (having the cell (1;12) selected and visible rows spanning from 7 to 18), if you press ArrowUp repeatedly, you'll notice you can't go any further than cell (1;7). The table wrapper won't scroll up and the selected cell is apparently stuck on row 7. However, if you press ArrowUp N times, you'll need to press ArrowDown N times again to get back to the cell above. This suggests the selected row may be actually being decreased with each keystroke, but it doesn't update the view accordingly.

I have tested this demo in both Chrome and Firefox with the same result.

@komarovalexander
Copy link
Owner

komarovalexander commented Jul 11, 2024

Hi @cetetesoft

Regarding this behavior, could it be changed somehow to scroll by one row - ie showing rows 1 to 12, then 2 to 13, and so on?

im afraid this is default behavior of html table, see example https://stackblitz.com/edit/table-keyboard-navigation-ts-prknhj?file=Demo.tsx click by cell and change focus using "Tab" key

@komarovalexander komarovalexander added the bug Something isn't working label Jul 11, 2024
@komarovalexander
Copy link
Owner

@cetetesoft

if you press ArrowUp N times, you'll need to press ArrowDown N times again to get back to the cell above

maybe it is not so obvious, but there are no rendered rows above, so you cant move the focus further. To fix that there is topInvisibleCount option in virtualScrolling so you can enable some items above visible line to be rendered as well. In this way ArrowUp will work https://stackblitz.com/edit/table-many-rows-ts-276fys?file=Demo.tsx

@komarovalexander komarovalexander removed the bug Something isn't working label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants