Skip to content

Commit fb2b602

Browse files
authored
feat(ui): allows opting out of popup closing logic (#15407)
This PR allows you to add interactive elements into a popup and not have them close the popup when clicking them, by adding the `data-popup-prevent-close` data attribute.
1 parent 345a9c7 commit fb2b602

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/ui/src/elements/Popup/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ export const Popup: React.FC<PopupProps> = (props) => {
319319

320320
const handleActionableClick = useEffectEvent((e: MouseEvent) => {
321321
const target = e.target as HTMLElement
322+
323+
// Allow opting out with data-popup-prevent-close attribute on element or ancestor
324+
if (target.closest('[data-popup-prevent-close]')) {
325+
return
326+
}
327+
322328
// Check if the clicked element or any ancestor is an actionable element
323329
const actionable = target.closest('button, a[href], [role="button"], [role="menuitem"]')
324330
if (actionable && popupRef.current?.contains(actionable)) {

0 commit comments

Comments
 (0)