Skip to content

Commit 3f7eb8b

Browse files
committed
feat: redirect focus to first item if item was dragged to hidden location (#362)
1 parent 7c4d980 commit 3f7eb8b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

next-release-notes.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Features
22
- RTL mode can be used on default renderers, see [docs for details](https://rct.lukasbach.com//docs/guides/accessibility#right-to-left-mode-rtl) (#369)
3+
- Redirect focus to first item if focused item was dragged to hidden location (#362)
34

45
### Bug Fixes and Improvements
56
- Fixes an issue where not providing a submit button ref in a custom rename input renderer would prevent dismissing the input on blur (#368)

packages/core/src/controlledEnvironment/useControlledTreeEnvironmentProps.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ export const useControlledTreeEnvironmentProps = ({
4747
>(
4848
(item, treeId, setDomFocus = true) => {
4949
if ((autoFocus ?? true) && setDomFocus) {
50-
const newItem = getDocument()?.querySelector(
51-
`[data-rct-tree="${treeId}"] [data-rct-item-id="${item.index}"]`
52-
);
50+
const newItem =
51+
getDocument()?.querySelector(
52+
`[data-rct-tree="${treeId}"] [data-rct-item-id="${item.index}"]`
53+
) ??
54+
getDocument()?.querySelector(
55+
`[data-rct-tree="${treeId}"] [data-rct-item-id]`
56+
);
5357

5458
if (
5559
getDocument()?.activeElement?.attributes.getNamedItem(

0 commit comments

Comments
 (0)