Skip to content

Commit

Permalink
Handle visibility of children in a closed details element
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Oct 19, 2024
1 parent 118215f commit 0676276
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/details-element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/dom': patch
---

Children contained in a closed `details ` element are no longer treated as visible.
13 changes: 11 additions & 2 deletions packages/dom/src/utilities/bounding-rectangle/isOverflowVisible.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {getWindow} from '../execution-context/getWindow.ts';

/*
* Check if an element has visible overflow.
* @param element
Expand All @@ -6,9 +8,16 @@
*/
export function isOverflowVisible(
element: Element,
style = getComputedStyle(element)
style?: CSSStyleDeclaration
) {
const {overflow, overflowX, overflowY} = style;
if (
element instanceof getWindow(element).HTMLDetailsElement &&
element.open === false
) {
return false;
}

const {overflow, overflowX, overflowY} = style ?? getComputedStyle(element);

return (
overflow === 'visible' && overflowX === 'visible' && overflowY === 'visible'
Expand Down

0 comments on commit 0676276

Please sign in to comment.