Skip to content

Commit

Permalink
Merge pull request #30 from egeemirozkanjf/feat/role-based-ignore
Browse files Browse the repository at this point in the history
feat(dnd-builder): enforce role-based ignores in click outside
  • Loading branch information
ozsirmajotform authored Nov 27, 2023
2 parents 2cc815a + d8ddcde commit 1b526d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/withClickOutside.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';

const IGNORED_ROLES = [
'dialog',
];

function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
Expand All @@ -23,6 +27,7 @@ function withClickOutside(WrappedComponent) {
classList.contains(exceptionalClasses)
|| Array.from(classList).some(xClass => exceptionalClasses.includes(xClass))
|| exceptionalClasses.some(item => event.target.closest(`.${item}`))
|| IGNORED_ROLES.some(role => event.target.closest(`[role=${role}]`))
)
) {
return;
Expand Down

0 comments on commit 1b526d3

Please sign in to comment.