-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clicks propagate to the underlying control #32
Comments
Hi @adriano-repetti , Thanks for your remarks, but I can't understand what you would demonstrate on your issue, can you please provide me a codesandbox test case with the Expected and Actual Behaviors ? |
@yjose thank you for your quick reply. You can reproduce it simply with:
When you click on the link the popup correctly opens but the event isn't stopped and it also triggers the Expected behavior: when the click opens the popup then it stops propagating and it does not trigger any other action. Possibly a second click when the popup is already open goes through the normal path. Actual behavior: the first click opens the popup but it also passed to the underlying control which may have a default behavior or another click handler attached. Note: I don't know if to change this may be considered a breaking change but, in that case, you might expose a property (or a callback) to swallow events or not (default to the current behavior). |
fixed : <div onClick={() => console.log("I don't want to be called when trigger is clicked.")}>
<Popup
{...props}
trigger={<button>Button Trigger</button>}
onOpen={e => e.stopPropagation()}
onClose={e => e.stopPropagation()}>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo
voluptas s lore Lorem ipsum dolor sit amet consectetur adipisicing
elit. Nemo voluptas s loreLorem ipsum dolor sit amet consectetur
adipisicing elit. Nemo voluptas s loreLorem ipsum dolor sit amet
consectetur adipisicing elit. Nemo voluptas s lore
</p>
</Popup>
</div> see #74 |
Hi @yjose, I think the typescript definitions have to be adjusted for onOpen or onClose, since an event is taken as an argument |
Hi, there's no event for |
If
trigger
is a link<a>
andon
isclick
then click triggers both the popup and the navigation to the link (or itsonclick
, if any). For example:Click to open is useful also for tooltip for touch devices (where hover isn't available and/or annoying/confusing for the user). We may mimic the hover behavior we see, for example, on Safari for iOS devices: first click always trigger the popup, second click when popup is open is bubbled down to the target control:
We also need to change
closePopup()
:The text was updated successfully, but these errors were encountered: