Tree with virtualScroll: Inconsistent focus #12351
Labels
Component: Accessibility
Issue or pull request is related to WCAG or ARIA
LTS-PORTABLE
PRO Support
Issue was reported by PRO User
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
I understand that this may just be the result of default DOM
TAB
key behavior, but in terms howTAB
/Up
/Down
keys work in conjunction with virtual scroll its definitely inconsistent.If using
[virtualScroll]="true"
having node focused on, and changing the rendered range via mousescroll
orpgUp
/pgDown
keys breaks focus away from the node. This is understandable. The focused node is no longer in the rendered range.However, from user's perspective this is extremely confusing and illogical, that once the scroll passed some point, pressing
TAB
orDown
key, behaves differently then before. Same problems observed withTAB
+SHIFT
andLeft
andRight
keysOpen the link to the example and follow the steps I have posted in the "Steps to reproduce"
Environment
Nothing special (check the linked example)
Reproducer
https://stackblitz.com/edit/angular-ivy-bf4ajq
Angular version
14.0.2
PrimeNG version
14.0.2
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
not relevant
Browser(s)
Tested in latest Firefox & Chrome (on MacOS 12.4)
Steps to reproduce the behavior
Start without having a focus on the tree and pressing the
TAB
key:->
p-tree
gets focus->
up
/down
/pgUp
/pgDown
keys work as expected: scrolling content by 1-2ish items or by page up/downPress
TAB
again:-> first item in the tree gets the focus
->
down
key now moves the focus to next item in tree, up does the opposite,pgUp
/phDown
still shift visible area by page2.b. Clicking the node also puts focus on node, but this is not really relevant
Press
TAB
/down
keys repeatedly:-> focus will move to next node and so on...
-> when focus is on last visible node, pressing
TAB
/down
key will move focus to next but also shift visible area so newly focused node is visiblea. using
pgDown
/ mousescroll
down at least 3x the visible area away from last focused node, then pressTAB
:-> it will not focus on the node next to previously focused node
-> instead it will focus on the (probably) first "rendered" node in range, which may be very far down the tree from the previously focused node
= This is somewhat understandable, as if node is no longer in DOM, we cannot focus on it by calling
el.focus()
<< It would however be much more convenient that on
TAB
key rendered range should be reset to previous one so the next node in tree can be focused -- for better user experienceb. Attempt the same scenario as 4.a, just instead of pressing
TAB
, pressDown
key:-> The tree will shift down the visible area, losing the focus on previously focused node and not focusing on any other node
= This I fail to understand
<< Using keys
Up
/Down
should not lose the focus - for better user experienceUsing keys
Left
/Right
also works inconsistently, its just my example cannot show this (it was built for other purpose, sorry).Expected behavior
Using
TAB
,TAB
+SHIFT
,Down
orUp
key when having focus on a node, should always focus on the nearest node down/up, even in the case of virtual scroll enabled.Using
Left
or `Right`` key when having focus on a node, should always expand/collapse that node (or collapse parent node if node already collapsed), even in case of virtual scroll enabled.The text was updated successfully, but these errors were encountered: