-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Tree view component steals the focus when the last focused tree item gets removed from the DOM #1436
Comments
This was fixed in #1430, which hasn't been released yet. This decision was made because the logic didn't seem to serve a purpose and, once added, users have no easy way of opting out of it. Instead, we decided to remove it and let users opt in manually if they needed such a feature. @alenaksu just to make sure I'm understanding correctly, are you advocating for removing the behavior like I did in #1430? |
Update: confirmed from your comment on the original discussion. I should have posted an update there when we fixed this. I'll do that now! |
Yeah sorry I didn't know it was already fixed :S By the way, I just checked your changes, I think that instead of removing everything, it would be better to check whether the last focused item was removed from the dom, and in that case set |
Originally posted by @Lukinoh in #1428
I was wondering why do we focus the first available item when we remove the selected item ?
shoelace/src/components/tree/tree.ts
Lines 166 to 169 in 5f4de6d
Just to give a bit of context, I have a tree with a list of items, and based on a input search, the tree is filtered.
However, the behaviour is quite strange due to those lines.
When the selected item is removed from the list, it focuses the first element, and the focus of the input is lost, which is not very practical.
You can find a reproduction here.
To simplify the implementation, I just remove all the items, and add the filtered one, hence the behaviour happens each time.
Best regards.
The text was updated successfully, but these errors were encountered: