You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
found an issue with the onOutsideClick handler. It get fired even if I click input field inside the popup.
(Note that this is not duplicate with previous reported issue)
If I render SweetAlert but don't show it yet and later on change the show:true, then this invalid behavior happens. If I have show:true on initial render time, then everything works.
Looks like that if it's show:false, when registerOutsideClickHandler get executed, it document.getElementsByClassName('sweet-alert') returns null (of course because the popup is not created.
Found out that if I move the registerOutsideClickHandler from componentDidMount after the place in setupWithProps where it creates the popup then it starts to work.
The text was updated successfully, but these errors were encountered:
Sorry for late reply. I think we can avoid handler be executed when targetNode is null or undefined.
export default function outsideTargetHandlerFactory(targetNode, eventHandler) {
return (evt) => {
evt.stopPropagation();
if (!targetNode) return; // <------- Added this line should fix this
let current = evt.target;
let found = false;
while (current.parentNode) {
found = isDOMEquals(current, targetNode);
if (found) return;
current = current.parentNode;
}
eventHandler(evt);
};
}
Hi,
found an issue with the
onOutsideClick
handler. It get fired even if I click input field inside the popup.(Note that this is not duplicate with previous reported issue)
If I render
SweetAlert
but don't show it yet and later on change theshow:true
, then this invalid behavior happens. If I haveshow:true
on initial render time, then everything works.Looks like that if it's
show:false
, whenregisterOutsideClickHandler
get executed, itdocument.getElementsByClassName('sweet-alert')
returns null (of course because the popup is not created.Found out that if I move the
registerOutsideClickHandler
fromcomponentDidMount
after the place insetupWithProps
where it creates the popup then it starts to work.The text was updated successfully, but these errors were encountered: