Skip to content

Commit 7c2bd81

Browse files
fix: remove inert if user cycles through whole list/dnd multiple times via keyboard dnd (#8581)
the root cause is because in a virtualizer node reuse/reorder case, we were removing the node from the hidden nodes prematurely even though it was going to be readded immediately after, causing the ref count to erroneously increment by 1 again Co-authored-by: Robert Snow <[email protected]>
1 parent b4b406c commit 7c2bd81

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/@react-aria/overlays/src/ariaHideOutside.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,6 @@ export function ariaHideOutside(targets: Element[], options?: AriaHideOutsideOpt
143143
// If the parent element of the added nodes is not within one of the targets,
144144
// and not already inside a hidden node, hide all of the new children.
145145
if (![...visibleNodes, ...hiddenNodes].some(node => node.contains(change.target))) {
146-
for (let node of change.removedNodes) {
147-
if (node instanceof Element) {
148-
visibleNodes.delete(node);
149-
hiddenNodes.delete(node);
150-
}
151-
}
152-
153146
for (let node of change.addedNodes) {
154147
if (
155148
(node instanceof HTMLElement || node instanceof SVGElement) &&

packages/@react-aria/overlays/test/ariaHideOutside.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ describe('ariaHideOutside', function () {
406406
let [count, setCount] = useState(0);
407407
let items = ['row1', 'row2', 'row3', 'row4', 'row5'];
408408
if (count === 1) {
409-
items = ['row2', 'row3', 'row4', 'row5', 'row1'];
409+
items = ['row2', 'row1', 'row3', 'row4', 'row5'];
410+
} else if (count === 2) {
411+
items = ['row2', 'row3', 'row1', 'row4', 'row5'];
410412
}
411413

412414
return (
@@ -426,9 +428,11 @@ describe('ariaHideOutside', function () {
426428
let row = getByTestId('row1');
427429
let revert = ariaHideOutside([button]);
428430

431+
act(() => button.click());
432+
await Promise.resolve();
429433
act(() => button.click());
430434
await Promise.resolve();
431435
revert();
432-
expect(row).not.toHaveAttribute('aria-hidden', 'true');
436+
expect(row.parentElement).not.toHaveAttribute('aria-hidden', 'true');
433437
});
434438
});

0 commit comments

Comments
 (0)